Solved

How do i compare first letter with my string?

Posted on 2009-07-09
1
173 Views
Last Modified: 2012-05-07
I want to find a letter in my string.

Let say I have a string with an "A"
Then I have another string. I want this to see if the first letter in the string is "A"

Example
Andersson  //This one is true. First letter A
Walter    //This one is false. First letter W

What letter comes into my method is never known. Sometimes an A sometimes B and so on
0
Comment
Question by:Mickeys
1 Comment
 
LVL 6

Accepted Solution

by:
ahmad2121 earned 500 total points
ID: 24816744

string x;

char someChar;

x = "Anderson";

someChar = 'A';

if (x.IndexOf(someChar) == 0)

{

 //code

}

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Handling arrays 14 35
Build JSON from table records 17 41
Calling stored proc in EDMX 11 19
bulid json format 3 21
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now