Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
RefactorExtractMetod();
RefactorExtractM...
for (int i = 0; i < args.Length; i++)
Console.WriteLine("Arg: {0}", args[i]);
return 0;
}
}
}
namespace ConsoleApplication...
class Program
{
static void Main(string[] args)
{
Console.WriteLine("C format: {0:C}", 99989.987);
Console.WriteLine("D6 f...
}
}
}
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
string[] books = { "complex algori...
static void Main(string[] args)
{
string userIsDone = "";
do
{
Console.Write("Are you done? [yes] [no]: ");
userIsDone = C...
default:
Console.WriteLine("will .. good luck with that ");
break;
}
Console.ReadLine();
}
}
namespace EnmiinJishee
{
clas...
}
}
}
namespace ObjectMethods
{
class Person
{
public Person(string fname, string lname, string s, byte a)
{
firstname = f...
Console.WriteLine("-> Fred's base class: {0}", fred.GetType());
Person p2 = fred;
Object o = p2;
if (o.Equals(fred) && p2....
lastname = lname;
SSN = s;
age = a;
}
public string firstname;
public string lastname;
public string SSN;
public byte age;...
{
static void Main(string[] args)
{
string Sdate = "2010-11-10";
DateTime CurrentDate = DateTime.Now;
Console.WriteLine(Co...
Console.WriteLine("Date t format:" + currdate.ToString("t"));
Console.WriteLine("Date U format:" + currdate.ToString("U"))...
Console.WriteLine(s.Insert(0, "hey"));
Console.ReadLine();
}
}
}
namespace ConsoleApplication21
{
class Program
{
static v...
Upcoming SlideShare
Loading in …5
×

Bodlogiin code

2,989 views

Published on

  • Be the first to comment

Bodlogiin code

  1. 1. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { RefactorExtractMetod(); RefactorExtractMetod(); Console.ReadLine(); } private static void RefactorExtractMetod() { Console.Title = "Application"; Console.ForegroundColor = ConsoleColor.Yellow; Console.BackgroundColor = ConsoleColor.Blue; Console.WriteLine("****************************************"); Console.WriteLine("*********** Welcome ********************"); Console.WriteLine("****************************************"); Console.BackgroundColor = ConsoleColor.Black; } } } namespace ConsoleApplication3 { class Program { public static int Main(string[] args) {
  2. 2. for (int i = 0; i < args.Length; i++) Console.WriteLine("Arg: {0}", args[i]); return 0; } } } namespace ConsoleApplication4 {
  3. 3. class Program { static void Main(string[] args) { Console.WriteLine("C format: {0:C}", 99989.987); Console.WriteLine("D6 format: {0:D6}", 99999); Console.WriteLine("E format: {0:E}", 99999.76543); Console.WriteLine("F3 format: {0:F3}", 99999.9999); Console.WriteLine("N format: {0:N}", 99999); Console.WriteLine("X format: {0:X}", 99999); Console.WriteLine("x format: {0:x}", 99999); Console.ReadLine(); } } } namespace ConsoleApplication5 { class StringFormat { static void Main(string[] args) { string FormatStr; FormatStr = String.Format("Don't you wish you had {0:c} in your account?", 99989.987); Console.WriteLine(FormatStr); Console.ReadLine();
  4. 4. } } } namespace ConsoleApplication7 { class Program { static void Main(string[] args) { string[] books = { "complex algoritm", "do you remember", "C and C++" }; foreach (string s in books) Console.WriteLine(s); int[] myints = { 10, 20, 30, 40 }; foreach (int i in myints) Console.WriteLine(i); Console.ReadLine(); } } } namespace ConsoleApplication8 { class Program {
  5. 5. static void Main(string[] args) { string userIsDone = ""; do { Console.Write("Are you done? [yes] [no]: "); userIsDone = Console.ReadLine(); Console.WriteLine("In while loop"); } while (userIsDone.ToLower() != "yes"); } } } namespace ConsoleApplication9 { class Program { static void Main(string[] args) { Console.WriteLine("1 [C#], 2 [VB]"); Console.Write("please pick you language preference: "); string langChoice = Console.ReadLine(); int n = int.Parse(langChoice); switch (n) { case 1: Console.WriteLine("Good choice, C# is a fine language"); break; case 2: Console.WriteLine("Good choice, VB is a fine language"); break;
  6. 6. default: Console.WriteLine("will .. good luck with that "); break; } Console.ReadLine(); } } namespace EnmiinJishee { class Enum1 { enum EmpType { Boss=1, Manager=2, Ahlagch=3, Ajilchin=4, } static void Main(string[] args) { Array obj = Enum.GetValues(typeof(EmpType)); Console.WriteLine("This enum has {0} members.", obj.Length); foreach (EmpType e in obj) { Console.Write("string Name: {0},", e.ToString()); Console.Write("int: ({0}),",Enum.Format(typeof(EmpType),e,"D")); Console.Write("hex: ({0})n,", Enum.Format(typeof(EmpType), e, "X")); Console.ReadLine(); }
  7. 7. } } } namespace ObjectMethods { class Person { public Person(string fname, string lname, string s, byte a) { firstname = fname; lastname = lname; SSN = s; age = a; } public Person() { } public string firstname; public string lastname; public string SSN; public byte age; static void Main(string[] args) { Console.WriteLine("*******Working with Object***********n"); Person fred = new Person("Fred", "Clark", "111 - 11 - 1111", 20); Console.WriteLine("-> Fred.Tostring: {0}",fred.ToString()); Console.WriteLine("-> Fred.GetHashCode: {0}", fred.GetHashCode());
  8. 8. Console.WriteLine("-> Fred's base class: {0}", fred.GetType()); Person p2 = fred; Object o = p2; if (o.Equals(fred) && p2.Equals(o)) Console.WriteLine("fred, p2,& o are referencing the same object."); Console.ReadLine(); } } } namespace ObjectMethods { class Person { public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendFormat("FirstName={0}", this.firstname); sb.AppendFormat("LastName={0}", this.lastname); sb.AppendFormat("SSN={0}", this.SSN); sb.AppendFormat("Age={0}", this.age); return sb.ToString(); } public Person(string fname, string lname, string s, byte a) { firstname = fname;
  9. 9. lastname = lname; SSN = s; age = a; } public string firstname; public string lastname; public string SSN; public byte age; static void Main(string[] args) { Console.WriteLine("*******Working with Object***********n"); Person fred = new Person("Fred ", "Clark ", "111 - 11 - 1111 ", 20); Console.WriteLine("-> Fred.Tostring: {0}", fred.ToString()); Console.WriteLine("-> Fred.GetHashCode: {0}", fred.GetHashCode()); Console.WriteLine("-> Fred's base class: {0}", fred.GetType()); Person p2 = fred; Object o = p2; if (o.Equals(fred) && p2.Equals(o)) Console.WriteLine("fred, p2,& o are referencing the same object."); Console.ReadLine(); } } } namespace ConsoleApplication19 { class Program
  10. 10. { static void Main(string[] args) { string Sdate = "2010-11-10"; DateTime CurrentDate = DateTime.Now; Console.WriteLine(Convert.ToString(DateTime.Now)); Console.WriteLine(CurrentDate.ToString()); CurrentDate = Convert.ToDateTime(Sdate); Console.WriteLine(CurrentDate); } } } namespace ConsoleApplication28 { class Program { static void Main(string[] args) { //string sdate = "2010-02-21"; //CurrDate = Convert.ToDateTime(sdate); DateTime currdate = DateTime.Now; Console.WriteLine("Date D format:"+currdate.ToString("D")); Console.WriteLine("Date d format:" + currdate.ToString("d")); Console.WriteLine("Date F format:" + currdate.ToString("F")); Console.WriteLine("Date f format:" + currdate.ToString("f")); Console.WriteLine("Date G format:" + currdate.ToString("G")); Console.WriteLine("Date g format:" + currdate.ToString("g")); Console.WriteLine("Date T format:" + currdate.ToString("T"));
  11. 11. Console.WriteLine("Date t format:" + currdate.ToString("t")); Console.WriteLine("Date U format:" + currdate.ToString("U")); Console.WriteLine("Date u format:" + currdate.ToString("u")); Console.WriteLine("Date s format:" + currdate.ToString("s")); Console.WriteLine("Date M format:" + currdate.ToString("M")); Console.WriteLine("Date m format:" + currdate.ToString("m")); Console.WriteLine("Date Y format:" + currdate.ToString("Y")); Console.WriteLine("Date y format:" + currdate.ToString("y")); Console.ReadLine(); } } } namespace ConsoleApplication20 { class Program { static void Main(string[] args) { Console.WriteLine("**********Fun with string**********"); string s = "Boy, this is taking a long time."; Console.WriteLine("--> s contains 'oy'?: {0}",s.Contains("oy")); Console.WriteLine("--> s contains 'Boy'?: {0}", s.Contains("Bey")); Console.WriteLine(s.Replace('.','!'));
  12. 12. Console.WriteLine(s.Insert(0, "hey")); Console.ReadLine(); } } } namespace ConsoleApplication21 { class Program { static void Main(string[] args) { Console.WriteLine("Everyone loves ' Hello World' "); Console.WriteLine("Everyone loves " Hello World" "); Console.WriteLine("aC:progdocumentpicture "); Console.WriteLine("Everyone loves ' Hello World' "); } } }

×