c# interview questions and answers - Reverse each word in a string using c#
Database, Information Technology
c# interview questions and answers
- Part 1 Can you store different types in an array in c#
- Part 2 What is jagged array
- Part 3 Why and when should we use an abstract class
- Part 4 What are the advantages of using interfaces
- Part 5 Recursive function c# example
- Part 6 Real time example of recursion
- Part 7 Storing different list types in a single generic list
- Part 8 Can an abstract class have a constructor
- Part 9 Call an abstract method from an abstract class constructor
- Part 10 What happens if finally block throws an exception
- Part 11 What is the difference between is and as keyword in c#
- Part 12 Difference between int and Int32 in c#
- Reverse each word in a string using c#
- C# abstract class virtual method
- C# default constructor access modifier
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.
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
https://www.youtube.com/user/kudvenkat/playlists?sort=dd&view=1
Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspot.com/2015/09/reverse-each-word-in-string-using-c.html
-
.Net
abstract
abstract class
advantage
Advantages
array
arraylist
AS
asp.net
benefits
block
C (Programming Language)
C#
c# class default constructor access modifier
c# interview questions and answers
c# reflection constructor access modifier
c# reflection constructor not found
c# reflection default constructor
c# reflection get constructor
c# reflection private constructor
c# reflection protected constructor
call
cast
catch
class
constructor
csharp
Data
DataTypes
difference between
Difference between int and Int32 in c#
different
directory
dot net
dotnet
Each
example
exception
exceptions
factorial
files
Finally
folder
frequently asked
function
generic
Handle
happens
int vs int32
interfaces
interview
is
jagged
keyword
LINQ
list
Lists
method
Number
occur
Operator
Overriding
purpose
question
questions
Real
Real-time
real-world
realtime
Recursion
recursive
reverse
Sentence
single
store
String
Structure
subdirectories
Throw
throws
time
try
Types
Use
using
virtual method
what
when
where
Why
Word
World