Posts Tagged ‘C#’

How to Convert Generic List To DataTable using C#

I have a task to need to get a DataTable, however, all existing objects are List, I need convert some of those lists to DataTables. Before I wrote my own code to do it. I searched internet and got 2 perfect articles which I need.
1: From DotNet Friends, By patriwala, Convert Generic List In [...]

Comments (1)

Optimizing C#

I got part of content from vcskicks.com
 7 Ways To Optimize C# Code
1. Use StringBuilder or String ?
  StringBuilder is faster mostly with big strings. This means if you have a loop that will add to a single string for many iterations then a StringBuilder class is definitely much faster than a string type.
However if you [...]

Leave a Comment

Fill a pair of data (text and value) to ComboBox .NET 2.0 Windows Application

In .NET 2.0 Windows Application, It is not easy to fill a pair of data (text, value) to a ComboBox, Most of examples just introduced the Display member and value member:
comboBox1.DisplayMember = “Desc”; comboBox1.ValueMember = “Code”; comboBox1.DataSource = dt;
Now let us don’t use DataSource and DisplayMember way:
class [...]

Leave a Comment

How to jump to specified tab page of Tab Control using C# code ?

If you wanna write code to jump to specified tab page of a tab control, you can not use Focus() method. or BringToFront(), Show() etc.
The right way is :
this.tabControl1.SelectedTab = this.tabPage3 ;

Leave a Comment

Public, Private, Protected and Internal in C#

Access Modifiers
(from: http://msdn.microsoft.com/en-us/library/ms173121.aspx)
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You specify the accessibility of a type or member when you declare it by using one of these access modifiers:
public
The type or member [...]

Leave a Comment

A site which has Math Interpolation source code

A site which has Math Interpolation source code. The code was written in C++. later I am going to change to C# for a project.
Koders site, Interpolation.cpp

Leave a Comment

Communicate with USB port using C#

I worked a GUI project using C# for an audio company. This project needs PC GUI program communicate with a hardware board which has a USB port so that the GUI and the board switch data.
The hardware board has a micro controller chip (MCU), Actually it is Microchip’s PIC. Then we know we can use [...]

Leave a Comment

How to load another event from one event in C# (如何在一个事件中调用另一个事件)

Assume we have aready hScrollBar event method:
Pravate void hScrollBar1_Scroll(object sender, EventArgs e){ …}
Now we would like to load it in a CheckBox event.
Normally people will do like this:
private void checkBox1_CheckedChanged(object sender, EventArgs e) { [...]

Leave a Comment