String to char
.net Char.Parse() method allow us to convert the value of the specified string to its equivalent Unicode character.
this method exists in System namespace. the Char.Parse() method require to pass a parameter named 's'. the 's' parameter
value type is System.String. this string contains a Unicode character or null.
this Char.Parse() method return value type is System.Char. the return value is a Unicode character that is equivalent to the single character of parameter 's'. finally we convert the string object to a char object.
the following .net c# example code demonstrate us how can we convert or parse a string object to char in an asp.net application.
this Char.Parse() method return value type is System.Char. the return value is a Unicode character that is equivalent to the single character of parameter 's'. finally we convert the string object to a char object.
the following .net c# example code demonstrate us how can we convert or parse a string object to char in an asp.net application.
string-to-char.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this section create a string variable.
string stringOfChar = "A";
Label1.Text = "string of single character..................<br />";
Label1.Text += stringOfChar;
//this line convert/parse/transform string to char.
//for this conversion you need a 1 character lenght string.
char c = char.Parse(stringOfChar);
Label1.Text += "<br /><br />converted char from string.........<br />";
Label1.Text += c;
Label1.Text += "<br /><br />type of the current instance .........<br />";
Label1.Text += c.GetType();
Label1.Text += "<br /><br />type of the current instance (string).........<br />";
Label1.Text += stringOfChar.GetType();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to char</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to char
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="string to char"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>

- String contains ignorecase
- How to append a substring to a string
- How to append a char to a string
- How to determine whether a string is equals to another string
- String equals case insensitive
- How to check whether a string ends with specific substring
- How to check whether a string starts with specific substring
- How to format a string as datetime yyyyMMdd
- How to convert a string to double
- How to convert a string to float