TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
533
2.4k
598.1k
Split String in C#
Mar 30 2017 1:31 AM
Hi,
I want to split integer from string. For that, I have done like this,
public
void
Main(
string
[] args)
{
string
obj =
"Rs. 1 to 100 employees."
;
int
A = 0;
int
B = 0;
string
[] listTurnOver = obj.Split(
new
[] {
' '
}, StringSplitOptions.RemoveEmptyEntries).ToArray();
bool
isfist =
true
;
for
(
int
i = 0; i < listTurnOver.Count(); i++)
{
int
temp = 0;
int
.TryParse(listTurnOver[i],
out
temp);
if
(temp != 0)
{
if
(isfist)
{
A = temp;
isfist =
false
;
}
else
{
B = temp;
}
}
}
}
Let's say, If my string is containing 3 intergers, then how can I split and assigned to another int vartible?
string
obj2 =
"1 to 100 employees with average of 10 percentage."
;
int
C = 0;
/*int c = ?*/
Reply
Answers (
5
)
insert value from dynamica drop down list to textbox MVC
How toshow name and insert values (name's ID ) from combobox