Counting number of words in a string - c# program, DOT NET Programming

Counting Number of Words in a String - C# Program

Anyone can suggest me the output of the following program.

using System;  

class CountWords

{

public static void Main()

{

string s = ""; // Declare 's' of string type  

Console.Write("Enter the string : ");    

S = Console.ReadLine(); // Read string from the console & save in 's'    

string [] words = s.Split(null);

// 'words' is an array of string type

// string 's' will split when a space (null) is encountered

// This will be saved into array words     

int i = words.Length; // Just count the lenght of array 'words'  

Console.WriteLine("The total number of words in the entered string : "+i);    

Console.ReadLine();

}

}

Posted Date: 2/12/2013 1:26:13 AM | Location : United States





This a very easy example... the output is:

 Enter the string : Daljit is making programs
 The total number of words in the entered string : 4

Posted by laura | Posted Date: 2/12/2013 1:27:49 AM


Related Discussions:- Counting number of words in a string - c# program, Assignment Help, Ask Question on Counting number of words in a string - c# program, Get Answer, Expert's Help, Counting number of words in a string - c# program Discussions

Write discussion on Counting number of words in a string - c# program
Your posts are moderated
Related Questions
I need Game development tutorials Project Description: We need video tutorials like lynda for game development using unity. You must have developed games before and need to s

#queWrite a XML with database with book details (BOOK ID, Title, Author, subject, published Year, language, vendor, price)stion..

Explain Forms authentication in detail. In the old ASP if you were said to create a login page and do authentication you have to do lot of custom coding. But now in ASP.NET tha

What is DBCC? The Database Consistency Checker Commands (DBCC) is used to check the logical and physical consistency of the database structure.The DBCC statements can fix and d

Webservices as such do not have any mechanism by which they can maintain their state. The Webservices can access ASP.NET intrinsic objects such as application, session and many mor

What are the ways of parsing XML document? The XML parser sits in between the XML document and the application who want to use the XML document. The Parser exposes a set of wel

Asp .net Facebook app project completion Project Description: We are a small development house in Singapore, and have a project which is 90 percent complete; thus our previou

What is the use of connection object? The connection objects are used to connect a data to the Command object. 1)An OleDbConnection object is used with the  OLE-DB provider

What is the DataContext class and how is it related to LINQ? After you add a LINQ to SQL Classes item to a project and open the O/R Designer, the empty design surface shows an

The ASP.NET new feature supports are shown below :- Better Language Support 1) The New ADO.NET Concepts have been implemented. 2) The ASP.NET supports complete  language