Format:
Recent snippets matching tags of enum
[Flags] public enum ApprovalStatusType { [Display(Description = "In Progress")] InProgress = 1, [Display(Description = "Pending Review")] PendingReview = 2, [Display(Description = "Need Changes")] NeedChanges = 4, [Display(Description = "Finished")]
61 Views
no comments
Dim funcs = (From x In [Enum].GetValues(GetType(SummaryFunc)) _ Order By x _ Select New With {.ID = CInt(x), .Name = [Enum].GetName(GetType(SummaryFunc), x)}).ToList
111 Views
no comments
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib>
76 Views
no comments
class PowerSet { static void Main(string[] args) { var set = Enumerable.Range(0, 8); foreach (var subSet in PowerSets(set)) Console.WriteLine(String.Join(" ", subSet)); } private static IEnumerable<IEnumerable<T>> PowerSets<T>(IEnumerable<T> masterSet)
145 Views
no comments
using System; using System.Diagnostics; using System.Runtime.CompilerServices; namespace Tpl.Samples { public enum MyEnum { None = 0, A = 1,
388 Views
no comments
namespace Test { public static class MyExtensions { public static IEnumerable<T> Where<T> (this IEnumerable<T> source, Func<T, bool> predicate) { foreach(var item in source) { if(predicate(item)) {
261 Views
no comments
Como faço para listar os tipos enumerados de força mais fácil e dinâmica num ComboBox? Essa foi a pergunta de uma grande amigo meu hoje. Confesso que não tinha muita idéia de como fazer. Imagine a situação: type TMeuTipo = (Tipo1, Tipo2, Tipo3, Tipo4, Tipo5); Como fazer isso aparecer em um ComboBox? Bem, podemos transformar isso em Strings e então adicioná-lo ao Combo, mais ou menos assim:
320 Views
no comments
public static PerpetualEnumerator<T> GetPerpetualEnumerator<T>(this IEnumerable<T> items) { return new PerpetualEnumerator<T>(items); }
316 Views
no comments
using System.Collections; using System.Collections.Generic; namespace nl4net { /// <summary> /// Wraps a standard IEnumerator<T> to provide /// iteration over a generic collection that automatically /// resets to the beginning once it reaches the end. /// </summary>
201 Views
no comments
//Enum declaration public enum RoleType { [Description("Allows access to public information")] Guest = 0, [Description("Allows access to the blog")] BlogReader = 4, } //Converter public static string ReadDescription<T>(T enumMember) {
170 Views
no comments
string str = "Dog"; Animal animal = (Animal)Enum.Parse(typeof(Animal), str); // Animal.Dog Animal animal = (Animal)Enum.Parse(typeof(Animal), str, true); // case insensitive
174 Views
no comments
using System; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Person[] people = new Person[] {
405 Views
no comments
/// <summary> /// Returns a list of SelectListItems from /// an Enum's string values. Useful for quickly filling /// lists. /// </summary> /// <param name="enumType">Type of an Enum</param> /// <param name="defaultValue">Optional default value as a string that is to be selected</param> /// <returns></returns> public static List<SelectListItem> GetSelectListFromEnum(Type enumType, string defaultValue) {
576 Views
no comments
public static T EnumConverter<T>(string value) { return (T)Enum.Parse(typeof(T), value); }
266 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
