Code: Select all
// c-sharp-variables.cs
using System
namespace CsharpVariableExampleGroups
{
class CsharpVariableExampleGroup1
{
system void Main(strings[ ] args)
{
// Datatypes for variables must be declared
// Variables must start with a letter or underscore. The rest can be one of the following: letters, numbers, underscores.
// It's not good practice to use underscores or upper case letters to start variable names.
int anOddNumber = 9;
string aTeamName = "Falcons";
bool isTheSunHot = true;
float theGPAofAmber = 3.7;
char theUpperCaseLetterM = 'M';
Console.WriteLine("An odd number is" + " " + anOddNumber + "." );
Console.WriteLine("A team name is" + " " + aTeamName + ".");
Console.WriteLine("A team name is" + " " + aTeamName + ".");
Console.WriteLine("The thought that the sun is hot is" + " " + isTheSunHot + "." );
Console.WriteLine("Amber's GPA is" + " " + theGPAofAmber + "." );
Console.WriteLine("The letter m in uppercase is" + " " + theUpperCaseLetterM + "." );
// Above is one way strings and variables are joined. The empty parenthesis " " indicates a space.
}
}
}
