Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Wednesday, June 30, 2010

Check the entered year is Leap year or not 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)
{
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-

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-

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;
}
}

Sunday, September 20, 2009

What is Open Source

Open Source - the term has been the centre stage of David vs Goliath fight in the software community. Be it Windows vs other operating systems, or Internet Explorer vs Mozilla; and now more recently, or more recently Microsoft vs Google, open source has been the rallying point of the so called 'resistance' to the proprietary regime, For developers within the software community, open source has transcended therole of a mere development methodology into a core life philosophy. Today, we hear of not just open source software, but also open source hardware, open sourche biotechnology, even open source politics!
Open souce is a methodology or approach towards the design and development of software with the intention of giving the user access to the source code; i.e. if you use open source software, not only will you be able to use it, you will be able to use it, you will also be able to see how it works, debut it, modify and redistribute it.
To elaborate and make the difference more clear, image the simplest entry level C++ programmed, the on that says "hello world".
If the program was proprietary, you would merely have access to the EXE file that upon execution would give a window with "hello world" written in it.
However, if the program is open source, you will also be given access to the code that the EXE File is compiled from.
The Open source Initiative, an organization committed to promoting open source uses the open source definition in order to determine if a software is open source or not. This definition, among other things specifies requirements of the license such as preventing, discrimination again any persons of groups and preventing discrimination against fields of endeavour.
One must not forget that there is a core difference between open source and free software. While they both embody the same core idea, the former still allows the commercial utilization of the code with the motive of profit. Many companies such as Red Hat gain significant revenues from sale, distribution, maintenance and consultancy services provided an open source software.

Tuesday, September 15, 2009

5 Simple Steps to add ado.net entity data Model in C# project

As I have started working on a C# with entity framework.A great tool from Microsoft to handle the databases through Entity framework. It’s amazing and definitely it will improve your confidence for database handling. It is so simple to implement ado.net entity data model in your C# project...
So let’s start to find the answer of - how can we connect a database with our c# project through entity framework?
In this example I am using the default database of Microsoft northwind.sdf.

1- At first open "add new item" dialog in project. Then select the ado.net entity data model(.edmx) option you can change the name of your data model as you like, here I am using the default name see in screen -1

Screen -1

2- When u create a data model then a dialog will appear with title "Entity Data model wizard", select option "Generate from database" and click on next button


Screen - 2

3- In next screen select new connection option and then a screen with "Connection properties" will appear, now click on change button and select database option for - Microsoft sql server compact, then click on browse button and select your database (default northwind.sdf its located in your Microsoft sql server compact edition folder) then click on ok see in screen – 3


Screen - 3


4- The wizard is automatically creating the required connection string for your database, click on next button -


Screen - 4


5- In next screen the tables of selected database is shown. Check it and then click on finish button see in screen - 5


Screen - 5


Finally the entity diagram of the required database and the tables are shown.


Screen - 6


You can also view the "app.config" xml file to view the connection string of your application –


Screen - 7


Now u can play with database easily.

Please tune in to get further tutorials regarding advanced filtering in queries, optimizing queries etc...

Reblog this post [with Zemanta]