From the category archives:

C#

PHP has come a long way in the last few years and now its one of the most popular known web language but has any one of us thought why the Name of the language is PHP and nothing else Or what is the full form of PHP. If No read through the complete post [...]

{ Comments }

In this post we explained how to write text to a file in C#. Today we will explain reading text from a file using the StreamReader class.
So create a file “text.txt” in the same directory where is the executable of the project. We will create a C# Console Application.
First, we must include this namespace, to [...]

{ Comments }

Using the Timer Class

by Shabbir on May 22, 2008

in C#

The timer class is often used in many applications. It’s very simple for using, like all the classes implemented in .Net Framework.
So create a C# Console project, we will try this class in a console application.
Include this namespace, so we can use the Timer class
using System.Timers;
Then in the Main() function put this code
Timer tm = [...]

{ Comments }

Adding items to list view is more difficult than adding items to list box. And in general the ListView control is more complex than the ListBox, and that makes it more difficult to work with.
So, in a C# project, create this form

The controls have the default names in Visual Studio 2008.

Than click on the little [...]

{ Comments }

Remove Unused Using Statements

by Shabbir on May 12, 2008

in C#

When we create a new C#.Net project (or other .Net project, , the editor includes the following using statements in the code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
But most of this included namespaces are unused, and you don’t know which of them you don’t need.
So, in Visual Studio 2008 there is a new [...]

{ Comments }

Adding items to this controls in .Net is very easy. To demonstrate that we will create a simple project with the following controls:

ListBox (name: listBox1)
ComboBox (name: comboBox1)
TextBox (name: textBox1)
Button (text: Add)

So, drag this controls from the toolbox and drop them on the main form one by one. Make a form like this

Now double click on [...]

{ Comments }

Usage Of RegistryKey Class

by Shabbir on May 8, 2008

in C#

The usage of RegistryKey class is very huge in many applications in which is needed to “remember” some settings of the application, and then load them when starting the application.
Today we will use the RegistryKey class for that issue. The application will save this informations in the registry when exiting:

Left
Top
Height
Width
FirstStart

And on start the application will [...]

{ Comments }

Read/Write Registry Keys

by Shabbir on May 5, 2008

in C#

Writing and reading to/from a registry key in .Net is really easy. All that is implemented in Microsoft.Win32 namespace, so at the start put this in the usings
using Microsoft.Win32;
Than in some function write this
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true)
.CreateSubKey("CodeItWell.com");
So, we are creating an object from the RegistryKey class, the object will open the sub key Software [...]

{ Comments }

In the previous post. We described the connection to the Microsoft Access database.
Now we will add some functionality to that. The user can insert diferent records.
For start, make a form like this (the names of the components are specified on the picture)

Now in the button1 event method insert this code

string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;";
OleDbConnection conn [...]

{ Comments }

The database connection is so easy to do in .Net Framework.
We will use Microsoft Access database for our example, the code will be written in C#.Net.
For start create one Microsoft Access database (db.mdb), and create a table (Info) with the folowing columns

ID (AutoNumber)
FirstName (Text)
LastName (Text)

Then in button event (it’s described here), add [...]

{ Comments }

Write To File in C#

by Shabbir on April 29, 2008

in C#

Today we will create a console application written in C# for writing to files.
We will use the StreamWriter class that is implemented in .Net Framework.
Create new C# project (Ctrl+Shift+N), and choose Console Application from the Templates menu on the right.
The editor will create the main code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace WriteToFile
{
class Program
[...]

{ Comments }

    About the Author

  • author photo

    My Name is Shabbir Bhimani and I am developer by profession in the field of applications, web and database. Currently doing full time online marketing and like to share my experiences on how you can make money online @ CodeItWell.com. Read more ...


    See how you can get in touch with me.