Posts

Strings in c#

Strings • Reference type • Represents a string of Unicode characters   string studentName ; string courseName = "Programming I"; string twoLines = “Line1\nLine2”;    Making Data Constant :     • Add the keyword const to a declaration • Value cannot be changed   • Standard naming convention • Syntax – const type identifier = expression; const double TAX_RATE = 0.0675;   const int SPEED = 70; const char HIGHEST_GRADE = ‘A’;  

Decimal Types and Boolean Variables

Decimal Types  • Monetary data items • As with the float, must attach the suffix ‘m’ or ‘M’ onto the end of a number to indicate decimal – Float attach ‘f’ or “F’ • Examples decimal endowmentAmount = 33897698.26 M ; decimal deficit; Boolean Variables   • Based on true/false, on/off logic • Boolean type in C# → bool • Does not accept integer values such as 0, 1, or -1    bool undergraduateStudent ; bool moreData = true ;            

Floating-point Types

Floating-point Types • May be in scientific notation with an exponent • n.ne±P – 3.2e+5 is equivalent to 320,000           – 1.76e-3 is equivalent to .00176   • OR in standard decimal notation • Default type is double     Examples of Floating-point Declarations  double extraPerson = 3.50;      // extraPerson originally set                                                 // to 3.50 double averageScore = 70.0;   // averageScore originally set                                ...