open a console application project in c# language in your editor and just paste the following code in your class's brackets -
static void Main(string[] args)
{
try
{
Console.Write("Please Enter the Year: ");
int year = int.Parse(Console.ReadLine());
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0))
{ Console.WriteLine("The year {0}, is a Leap Year", year);
}
else
{
Console.WriteLine("The year {0}, is not a Leap Year", year);
} }
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine(); }
Output is-
Wednesday, June 30, 2010
Create a Pyramid in C# Console
open a console application project in c# language in your editor and just paste the following code in your class's brackets -
static void Main(string[] args)
{
for (int i = 0; i < k =" i;" j =" 2"> 0; j--)
{
Console.Write("*"); }
Console.WriteLine("");
}
Console.ReadLine();
}
Output is-
static void Main(string[] args)
{
for (int i = 0; i < k =" i;" j =" 2"> 0; j--)
{
Console.Write("*"); }
Console.WriteLine("");
}
Console.ReadLine();
}
Output is-
Labels:
.Net,
C#,
Console Program,
Microsoft,
Programming
Monday, June 14, 2010
Search an Value in ListBox with compare to TextBox Text(Incremental Search) in C#
Here is an example to find the value in ListBox according to the text of Text box.
means when you type any character or word in textbox the matched value will be select in list box-
this 4 lines of code will remove your all headache to apply the incremental search option on listbox-
on TextBox's TextChangedEvent code like this-
private void textBox1_TextChanged(object sender, EventArgs e)
{
int index = listBox1.FindString(this.textBox1.Text);
if (0 <= index)
{
listBox1.SelectedIndex = index;
}
}
means when you type any character or word in textbox the matched value will be select in list box-
this 4 lines of code will remove your all headache to apply the incremental search option on listbox-
on TextBox's TextChangedEvent code like this-
private void textBox1_TextChanged(object sender, EventArgs e)
{
int index = listBox1.FindString(this.textBox1.Text);
if (0 <= index)
{
listBox1.SelectedIndex = index;
}
}
Labels:
.Net,
Incremental Search,
ListBox,
Microsoft
Subscribe to:
Posts (Atom)