C # simple example

Source: Internet
Author: User

Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Collections;

Namespace MyLunch
{
/// <Summary>
/// Switch usage
/// </Summary>
///
Public class Number
{
ArrayList list = new ArrayList ();
Int [] intList;
Public Number ()
{

}
Public void Input ()
{

Console. WriteLine ("This program allows you to enter three numbers and then sort them out in order. (Exit by X )");

String Input;

For (;;)
{
Input = Console. ReadLine ();
If ("X" = Input. ToUpper ())
Break;
Else
List. Add (Input );


}

}
Public void Sort ()
{
IntList = new int [list. Count];

Console. WriteLine (list. Count );

// Value.

For (int I = 0; I <list. Count; I ++)
{
IntList [I] = int. Parse (list [I]. ToString ());

}
For (int I = 0; I <intList. Length; I ++)
{
For (int j = I + 1; j <intList. Length; j ++)
{
Int temp;
If (intList [I]> intList [j])
{
Temp = intList [j];
IntList [j] = intList [I];
IntList [I] = temp;

 


}

}


}
}
Public void Display ()
{
Foreach (var item in intList)
{
Console. WriteLine (item. ToString ());

}
}
}
Class Program
{
Static void Main (string [] args)
{
Number number = new Number ();
Number. Input ();
Number. Sort ();
Number. Display ();



}
}
}

 

// Another example. They are simple.

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;

Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
Console. WriteLine ("welcome to this mall" + "" + "how much have you spent today? ");
Int input = int. Parse (Console. ReadLine ()));

String Display;
If (input <5)
{
Display = "you can leave now! ";

}
Else if (input> 5 & input <20)
{
Display = "reward you for a cup of coffee! ";
}
Else if (input> 20 & input <30)
&

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.