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
What are abstract classes? The features of the abstract class are as follows:- 1.     You can not create an object of the abstract class. 2.     The Abstract class is des

Write the basic syntax of a LINQ query in Visual Basic as well as in C#. In Visual Basic, the basic syntax of a LINQ query begins with the from clause and ends with the Select

Importance of IT governance Governing and managing information technology is a crucial activity in organizations to generate business value. According to Ross & Weill (2004), f

What is Object Relational Designer? The 0/R Designer provides a visual design surface to make LINQ to SQL entity classes and associations (relationships) that are based on obje

PhotoHandler add-on to display file names Project Description: I want a website with a photo gallery using PhotoHandler. I need the code added/ modified to display the image

Passport authentication A centralized service given by Microsoft, offers a single logon point for clients. Unauthenticated users are redirected to the Passport site

What is Difference between NameSpace and Assembly? Following are the differences among namespace and assembly: Assembly is physical grouping of logical units, Namespace, log

Types of Transactions in COM + .NET There are 5 types of transactions that can be used with COM+.   An object is whenever registered with the COM+ it has to abide either to any

Project Description: I have a website that I have prepared, but I would like someone to make it look nicer. Most of the functionality is there, but I need help with design which

Project Description: The software is developed to help individuals train both their subconscious and conscious mind so they can improve their life and get more success. - How