Exercise 3-11 (AllTheColorsOfTheRainbow, naming conventions)

Chapter_3     Exercise_3-10     Show_Properties Exercise_3-12







Exercise 3-11     TCS, p. 86


Exercise 3-11. Turn the AllTheColorsOfTheRainbow example into a program that compiles and runs.




AllTheColorsOfTheRainbow.cs     TCS, p. 84


public class AllTheColorsOfTheRainbow // PascalCase
{
int anIntegerRepresentingColors; // camelCase

void changeTheHueOfTheColor(int newHue)
{
anIntegerRepresentingColors = newHue;
}

public static void Main()
{
AllTheColorsOfTheRainbow all = new AllTheColorsOfTheRainbow();
System.Console.WriteLine(all.anIntegerRepresentingColors);
all.changeTheHueOfTheColor(1);
System.Console.WriteLine(all.anIntegerRepresentingColors);
}
}
/*
mcs AllTheColorsOfTheRainbow.cs
mono AllTheColorsOfTheRainbow.exe
0
1
*/




Note:  See Naming_Conventions on Wikipedia, camelCase and PascalCase on Wiktionary.









Chapter_3     Exercise_3-10     Show_Properties BACK_TO_TOP Exercise_3-12



Comments

Popular posts from this blog

Contents