filmov
tv
Reverse each word in a string using c#
Показать описание
reverse, each, word, string, using, c#, linq, dot net, .net, sentence,
In this video we will discuss how to reverse each word in a string using c#. This is a common c# interview question.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Reverse the following string
one two three four five
Output should be
eno owt eerht ruof evif
Here is the C# code that can do this
string inputString = "one two three four five";
string resultString = string.Join(" ", inputString
.Split(' ')
.Select(x =] new String(x.Reverse().ToArray())));
Console.WriteLine(resultString);
Make sure you have the following using declarations
using System;
using System.Linq;
Here is what is happening with the above code
Split the input string using a single space as the separator. Split() method returns a string array that contains each word of the input string.
Select method, constructs a new string array, by reversing each character in each word.
Join method converts the string array into a string.
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
In this video we will discuss how to reverse each word in a string using c#. This is a common c# interview question.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Reverse the following string
one two three four five
Output should be
eno owt eerht ruof evif
Here is the C# code that can do this
string inputString = "one two three four five";
string resultString = string.Join(" ", inputString
.Split(' ')
.Select(x =] new String(x.Reverse().ToArray())));
Console.WriteLine(resultString);
Make sure you have the following using declarations
using System;
using System.Linq;
Here is what is happening with the above code
Split the input string using a single space as the separator. Split() method returns a string array that contains each word of the input string.
Select method, constructs a new string array, by reversing each character in each word.
Join method converts the string array into a string.
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
Комментарии