CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of enum
C#
[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")]
by Domantas   October 31, 2011 @ 3:31am
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
by Thom Lamb   October 02, 2011 @ 10:15am
Tags: vb, .net, Linq, enum
111 Views
no comments
 
C++
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
by iscsi   July 27, 2011 @ 6:04am
76 Views
no comments
 
C#
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)
by ccmouse   April 01, 2011 @ 8:11pm
145 Views
no comments
 
C#
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
 
namespace Tpl.Samples
{
    public enum MyEnum
    {
        None = 0,
        A = 1,
by bnaya   January 28, 2011 @ 5:51am
Tags: HasFlag, Enum
388 Views
no comments
 
C#
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))
            {
by Vijay Sharma   January 06, 2011 @ 8:11am
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:
by Adriano Santos   August 27, 2010 @ 12:02pm
320 Views
no comments
 
C#
public static PerpetualEnumerator<T> GetPerpetualEnumerator<T>(this IEnumerable<T> items)
{
    return new PerpetualEnumerator<T>(items);
}
316 Views
no comments
 
C#
using System.Collections;
using System.Collections.Generic;
 
namespace nl4net
{
    /// <summary>
    /// Wraps a standard IEnumerator&lt;T&gt; to provide
    /// iteration over a generic collection that automatically 
    /// resets to the beginning once it reaches the end.
    /// </summary>
by Al Gonzalez   June 17, 2010 @ 9:08pm
201 Views
no comments
 
C#
//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)
{
by darek156   April 01, 2010 @ 1:50am
Tags: enums
170 Views
no comments
 
C#
string str = "Dog";
Animal animal = (Animal)Enum.Parse(typeof(Animal), str);  // Animal.Dog
Animal animal = (Animal)Enum.Parse(typeof(Animal), str, true); // case insensitive
by KMS   December 23, 2009 @ 9:09am
Tags: enum
174 Views
no comments
 
C#
using System;
using System.Linq;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Person[] people = new Person[] {
405 Views
no comments
 
C#
/// <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) 
{
by Rick Strahl   July 29, 2009 @ 4:33am
Tags: Enum, MVC, ASP.NET
576 Views
no comments
 
C#
public static T EnumConverter<T>(string value)
    {
        return (T)Enum.Parse(typeof(T), value);
    }
by Giuliano Lemes   July 28, 2009 @ 6:43am
266 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate