Tag Archives | c#

ASP.net

C# – Convert String Array to a List (.Net 2.0)

So you’ve got a C# string and you want to convert it to a List<string>.  Lists are one of the most efficient ways of storing…well…lists of things in .Net.  If you’re in .Net 3.0, it’s quite easy to go from a string array to a list by using the .ToList() function. If you’re stuck in .Net […]

Continue Reading
random_wrong

C# – Get a Random Number Between x and y

Here’s a quick function for getting random numbers in C#: Notice that you have to declare your instance of the Random class outside of the GetRandomInt function if you are going to be running this in a loop. “Why is this?” you ask. Well, the Random class actually generates pseudo random numbers, with the “seed” for […]

Continue Reading

C#: Convert Double to Integer…and other conversions

Type conversions and casting in C# are so whack!  Microsoft created the System.Convert class to bring some sanity and predictability to converting from one type to another in C#.  Without further ado, to convert a Double to an Integer, you can use:   int myInt = System.Convert.ToInt32(myDouble); The System.Convert class has the following methods: ToBoolean ToByte […]

Continue Reading
ASP.net

ASP.Net C# – PHP Equivalents

On this post, I will be collecting ASP.NET C# commands that I use frequently in PHP but I have to continually look up in the little bit of ASP.NET that I do.  PHP can be frustrating for its inconsistencies in syntax, but what is even more frustrating is when you’re trying to do something in […]

Continue Reading

Powered by WordPress. Designed by Woo Themes