Tag Archives: C#

Microsoft Visual C# is simple, modern, general-purpose, object-oriented programming language, included in the Microsoft Visual Studio. Visual C# is also mostly used in ASP.NET web sites and Windows applications.

Replace one date format to another date format in the entire string using Regular expression.

You can use the Regex.Replace method to replace one date format to another date format in the entire string. The following code example uses the Regex.Replace method to replace dates that have the form mm/dd/yy with dates that have the form dd-mm-yy. Continue reading Replace one date format to another date format in the entire string using Regular expression.

How to create Radio Buttons from a String Array in C#

This following example creates radio button controls and set their text from an array of strings programmatically. The example draws the radio button in vertical direction.

private void Form_load(object sender, EventArgs e)
{
    string[] string_Array = new string[3];
 
    string_Array[0] = "USA";
    string_Array[1] = "India";
    string_Array[2] = "Germany";
 
	DrawRadioButtons(string_Array);
}
 
private void DrawRadioButtons(string[] ArrayOfString)
{
    System.Windows.Forms.RadioButton[] btnRadio = new System.Windows.Forms.RadioButton[string_Array.Length];
 
    for (int i = 0; i < ArrayOfString.Length; ++i)
    {
        btnRadio[i] = new RadioButton();
        btnRadio[i].Text = ArrayOfString[i];
        btnRadio[i].Location = new System.Drawing.Point(10, 30 + i * 20);
        this.Controls.Add(btnRadio[i]);
    }
}

See the output on the windows form:
Continue reading How to create Radio Buttons from a String Array in C#