Pre work - KaterynaShydlovska/C- GitHub Wiki
using System; using System.Text;
namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!");
bool correct = true;
int num = 22;
double number = 10.4;
char l = 'k';
string name = "Kate";
Console.WriteLine("Correct: "+ correct);
Console.WriteLine("num: " + num);
Console.WriteLine("number double: "+ number);
Console.WriteLine("character: "+ l);
Console.WriteLine("Name: "+ name);
int bigestNum = Int32.MaxValue;
Console.WriteLine("------------------------");
Console.WriteLine($"Max intiger = {bigestNum}");
Console.WriteLine($"Max intiger + 1 = {bigestNum +1}");
var boolian = false;
var n = 10;
var doubleN = 22.05;
var letter = 'A';
var str = "String";
Console.WriteLine("------------------------");
Console.WriteLine("Boolian: " + boolian);
Console.WriteLine("num: " + n);
Console.WriteLine("number double: " + doubleN);
Console.WriteLine("character: " + letter);
Console.WriteLine("String: " + str);
Console.WriteLine("------------------------");
int x = 5;
int y = 2;
int z1 = x++;
int z2 = y++;
Console.WriteLine(" x = {0}, y = {1}, z1 = {2}, z2 = {3} ", x, y, z1, z2);
int z = 6;
int a = x + y + z;
int b = (x - y) * z;
int c = x + y -z;
bool isEven;
//bool divisible;
if( x % 2 == 0)
{
isEven = true;
}
else
{
isEven = false;
}
Console.WriteLine(isEven);
if( y % 3 == 0)
{
isEven = false;
}
else
{
isEven = true;
}
Console.WriteLine(isEven);
double day = 12.2020;
double result = Math.Round(day, 3);
Console.WriteLine(result);
string s = "Here\nwe\nare!";
string st = "Here we are!";
Console.WriteLine(s);
Console.WriteLine(st);
string res = "string to cincut";
Console.WriteLine(string.Concat(res, st));
Console.WriteLine(res.Length);
string lastName = "Shydlovska";
int index = lastName.Length / 2;
Console.WriteLine("index " + index);
Console.WriteLine(" Three char: " + lastName[0] + lastName[index] + lastName[lastName.Length - 1]);
Console.WriteLine(res.ToUpper());
Console.WriteLine(res.ToLower());
StringBuilder sb = new StringBuilder("BigMac", 5);
sb.Remove(0, 1);
sb.Remove(sb.Length-1, 1);
Console.WriteLine(sb.ToString());
string k= "string";
string m = " another str";
for(int i=0; i < k.Length; i++)
{
if (m.Contains(k[i]))
{
Console.WriteLine(i);
break;
}
}
if (k.Contains(m))
{
Console.WriteLine(true);
}
else
{
Console.WriteLine(false);
}
string splitIt = "To to to, boo";
splitIt.Split(" ");
foreach(var word in splitIt)
{
Console.WriteLine(word);
}
const string newString = "const string";
string fromNewString = String.Format("The current string has inside < {0} > other string", newString);
Console.WriteLine(fromNewString);
double price = 19.165;
Console.WriteLine("Gas price = {0:c2}", price);
bool bo = false;
int twentyTwo = 22;
double two = 22.05;
char character = 'D';
string w = bo.ToString();
string zz = twentyTwo.ToString();
string q = two.ToString();
string r = character.ToString();
Console.WriteLine(w);
Console.WriteLine(zz);
Console.WriteLine(q);
Console.WriteLine(r);
bool e = bool.Parse(w);
int h = Int32.Parse(zz);
double f = Double.Parse(q);
char u = Char.Parse(r);
Console.WriteLine(e);
Console.WriteLine(h);
Console.WriteLine(f);
Console.WriteLine(u);
cStruct localStruct;
localStruct.X = 1;
localStruct.Y = 2;
localStruct.TrueOrFalse = true;
Console.WriteLine("Struct X: {0}, Y: {1}, TrueOrFalse: {2}", localStruct.X, localStruct.Y, localStruct.TrueOrFalse);
}
}
//public enum Seasons // { // Spring = green, // Summer = colorful, // Autumn = yellow, // Winter = white, // }
// Console.WriteLine(Seasons.Spring);
//????
public struct cStruct { public int X; public int Y; public bool TrueOrFalse;
}
}
// COMMENTS
// singleline comment
/* multiline
- comment
- ..... */
/// /// ///