Jun 23, 2024
dotnet desktop development with size around 3GBprogram.cs)Console.WriteLine("Hello World");
Console.ReadLine(); // To keep the console window open
WriteLine statements to draw e.g., a triangle.+ to combine strings.Length: Get length of a string.ToUpper(): Convert to uppercase.Contains(): Check if substring is present.Substring(startIndex, length): Extract part of a string+, -, *, /, %.Abs(), .Pow(), .Sqrt(), .Max(), .Min(), .Round()*Console.ReadLine()Convert.To<type>()if (condition)
{
// Execute this if condition is true
}
else
{
// Execute this if condition is false
}
>, <, >=, <=, ==, !=, &&, ||if-else structures to handle multiple conditionsswitch(variable)
{
case value1:
// Code block
break;
case value2:
// Code block
break;
default:
// Code block
break;
}
while (condition)
{
// Code block
}
while, but guarantees the block executes at least once
do
{
// Code block
} while (condition)
for (int i = 0; i < limit; i++)
{
// Code block
}
try
{
// Code block
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
// Code block
}
DivideByZeroException, FormatException)public class ClassName
{
public string attributeName;
public ClassName(string parameterName)
{
this.attributeName = parameterName;
}
}
ClassName obj = new ClassName("value");
Console.WriteLine(obj.attributeName);
public ClassName(string attr1, string attr2)
{
this.attr1 = attr1;
this.attr2 = attr2;
}
public class ClassName
{
public bool MethodName()
{
// Code block
}
}
private string varName;
public string VarName
{
get { return varName; }
set { varName = value; }
}
public static int count = 0;
public static void StaticMethod()
{
// Code block
}
public class SubClass : SuperClass
{
// Additional or overridden functionality
}
virtual and override keywords
public virtual void SomeMethod()
{
// Code block
}
public override void SomeMethod()
{
// New code block
}