Posted in October 2012

control strucuture

using System; namespace Wrox {      class MainEntryPoint() {            static public void main() {                Console.WriteLine(“type in a string”);                string input;                input = Console.ReadLine();                if (input == “”) {                       Console.WriteLine(“empty string”);                } else if (input.Length < 5) {                       Console.WriteLine(“string is short”);                } else if (input.Length > 10) … Continue reading

Even more C#

using System; class StringExample { public static int main() { string s1 = “a string”; string s2 = s1;// copy, not reference to the same address Console.WriteLine(“s1 is ” +  s1); Console.WriteLine(“s2 is ” + s2); s1 = “another string”; Console.WriteLine(“s1 is ” + s1); Console.WriteLine(“s2 is ” + s2); return 0; } “s1 is … Continue reading

More C# stuff

csc First.cs // compiling variables must be declared before using. var a=”123″; // will automatically infer variable as a string In a for loop, you can have a “throw away” counter variable for (int i=0; i<10; i++) { Console.WriteLine(i); }// end of for, i fell out of scope int is 32 bit float is 32 … Continue reading

Hello world C#!

using System; namespace Wrox { public class MyFirstClass { static void main() { Console.WriteLine(“Hello world”); return; } } }