Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
AnswerRe: Data Structure Pin
Guffa16-Nov-08 13:05
Guffa16-Nov-08 13:05 
AnswerRe: Data Structure Pin
Mycroft Holmes16-Nov-08 15:15
professionalMycroft Holmes16-Nov-08 15:15 
QuestionCasting Error Pin
Vimalsoft(Pty) Ltd16-Nov-08 4:02
professionalVimalsoft(Pty) Ltd16-Nov-08 4:02 
AnswerRe: Casting Error Pin
Wendelius16-Nov-08 4:38
mentorWendelius16-Nov-08 4:38 
GeneralRe: Casting Error Pin
Guffa16-Nov-08 6:58
Guffa16-Nov-08 6:58 
GeneralRe: Casting Error Pin
Wendelius16-Nov-08 9:44
mentorWendelius16-Nov-08 9:44 
AnswerRe: Casting Error Pin
Guffa16-Nov-08 7:01
Guffa16-Nov-08 7:01 
GeneralRe: Casting Error Pin
Vimalsoft(Pty) Ltd16-Nov-08 9:25
professionalVimalsoft(Pty) Ltd16-Nov-08 9:25 
GeneralRe: Casting Error Pin
Guffa16-Nov-08 13:10
Guffa16-Nov-08 13:10 
Answer[Resolved]Re: Casting Error Pin
Vimalsoft(Pty) Ltd16-Nov-08 19:29
professionalVimalsoft(Pty) Ltd16-Nov-08 19:29 
QuestionSolution for Tower of Hanoi with Breadth First Search Algorithm ? Pin
Mohammad Dayyan16-Nov-08 2:34
Mohammad Dayyan16-Nov-08 2:34 
AnswerRe: Solution for Tower of Hanoi with Breadth First Search Algorithm ? Pin
#realJSOP16-Nov-08 3:01
professional#realJSOP16-Nov-08 3:01 
GeneralRe: Solution for Tower of Hanoi with Breadth First Search Algorithm ? Pin
Mohammad Dayyan16-Nov-08 16:16
Mohammad Dayyan16-Nov-08 16:16 
AnswerRe: Solution for Tower of Hanoi with Breadth First Search Algorithm ? Pin
Christian Graus16-Nov-08 12:58
protectorChristian Graus16-Nov-08 12:58 
GeneralRe: Solution for Tower of Hanoi with Breadth First Search Algorithm ? Pin
Mohammad Dayyan16-Nov-08 16:15
Mohammad Dayyan16-Nov-08 16:15 
GeneralRe: Solution for Tower of Hanoi with Breadth First Search Algorithm ? Pin
Paul Conrad16-Nov-08 17:46
professionalPaul Conrad16-Nov-08 17:46 
Questiondatabind pictureBox control to Northwind Employees table Pin
papori123416-Nov-08 2:25
papori123416-Nov-08 2:25 
Question32Bits Depth Images to 24Bits Depth Image c# Pin
saberbladez16-Nov-08 2:11
saberbladez16-Nov-08 2:11 
AnswerRe: 32Bits Depth Images to 24Bits Depth Image c# Pin
#realJSOP16-Nov-08 3:02
professional#realJSOP16-Nov-08 3:02 
AnswerRe: 32Bits Depth Images to 24Bits Depth Image c# Pin
Christian Graus16-Nov-08 13:00
protectorChristian Graus16-Nov-08 13:00 
QuestionMaking a function return a type value specified Pin
Chris Copeland16-Nov-08 2:09
mveChris Copeland16-Nov-08 2:09 
AnswerRe: Making a function return a type value specified Pin
Giorgi Dalakishvili16-Nov-08 3:05
mentorGiorgi Dalakishvili16-Nov-08 3:05 
AnswerRe: Making a function return a type value specified Pin
#realJSOP16-Nov-08 3:13
professional#realJSOP16-Nov-08 3:13 
I use this function to convert an integer value to a suitable enum ordinal. It tries to find a valid ordinal based on the specified integer parameter. If it can't find one, it returns the specified default value.

enum MyEnum { None=0, Few=1, Some=2, Many=4, CrapLoad=8, All=128};

public static T IntToEnum < t > (int value, T defaultValue)
{
	T enumValue = (Enum.IsDefined(typeof(T), value)) ? (T)(object)value : defaultValue;
	return enumValue;
}

//Usage:

// Given the value of x, IntToEnum would return MyEnum.All because there 
// is no ordinal with the value of x.
int x = 3;
MyEnum myEnum = IntToEnum < MyEnum > (x, MyEnum.All);

// Given the value of x, IntToEnum would return MyEnum.Many because there 
// *is* an ordinal with the value of x.
x = 4;
myEnum = IntToEnum < MyEnum > (x, MyEnum.All);


Is this a sufficient example?


"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


GeneralRe: Making a function return a type value specified Pin
Chris Copeland16-Nov-08 3:40
mveChris Copeland16-Nov-08 3:40 
QuestionHow to Invoke Parent Form Event Handler Pin
swjam16-Nov-08 1:56
swjam16-Nov-08 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.