Solved

How do i compare first letter with my string?

Posted on 2009-07-09
1
174 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Data Saving 5 56
Problem to error 4 47
What .NET URL re-routing tool did I use? 2 38
C#.NET and microsoft certification. 3 34
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

24 Experts available now in Live!

Get 1:1 Help Now