开发者

How to take a first character from the string

开发者 https://www.devze.com 2023-04-11 16:29 出处:网络
Using VB.Net & SQ开发者_JS百科L Server 2005 Dim S as string s = \"Rajan\" s = \"Sajan\" I want to take a first character from the string (s)

Using VB.Net & SQ开发者_JS百科L Server 2005

Dim S as string
s = "Rajan"
s = "Sajan"

I want to take a first character from the string (s)

Expected Output

R
S

Need VB.Net Code Help


Try this..

Dim S As String
S = "RAJAN"
Dim answer As Char
answer = S.Substring(0, 1)


Try this:

Dim s = "RAJAN"
Dim firstChar = s(0)

You can even do this:

Dim firstChar = "RAJAN"(0)


Use chars:

Dim firstChar As char;
firstChar = s.Chars(0);

http://vb.net-informations.com/string/vb.net_String_Chars.htm


"ABCDEFG".First returns "A"

Dim s as string

s = "Rajan"
s.First
'R

s = "Sajan"
s.First
'S
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号