Q: How does the c
Laparoscopic diagn
The present invent
Bahrain’s Foreign
Newport Beach, Cal
A group of interna
Methotrexate-assoc
Q: PHP Regex - No
Solar Power in Okl
Gastric varices: p

Q: How to access
Q: How to convert
Q: How can I add
The present invent
Q: XPATH querying
Oil and water, yin
Methanotrophs colo
Q: How to set the
LOS ANGELES -- It'
We’re back! Join h
Q: How to use the function that has a return type with a boolean and a bool in the same function? I want to make a program that accepts a string of characters, and the text is changed into the English equivalent, then I have a problem, can't make this function return either the number of words(including special characters and punctuation), or the number of sentences. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication6 { class Program { static void Main(string[] args) { Console.Write("Enter a sentence: "); string Sentence = Console.ReadLine(); int NumberOfWords = convertWord(Sentence); int NumberOfSentences = convertSentence(Sentence); Console.WriteLine("Number of words: " + NumberOfWords); Console.WriteLine("Number of sentences: " + NumberOfSentences); Console.ReadLine(); Console.ReadLine(); } static int convertSentence(string Text) { int NumberOfSentences = 0; int Length = Text.Length; bool IsCapital = true; bool IsVowel = false; for (int i = 0; i < Length; i++) { if (Char.IsLetter(Text[i]) && !Char.IsWhiteSpace(Text[i])) { IsCapital = true; } if (IsCapital) { if (Char.IsUpper(Text[i]) || Char.IsLower(Text[i])) { IsVowel = true; } else { NumberOfSentences++; IsCapital = false; } } } return NumberOfSentences; } static int convertWord(string Text) { int NumberOfWords = 0; int Length = Text.Length; bool IsCapital = true; bool IsVowel = false; for (int i = 0; i < Length; i++) { if (Char.IsLetter(Text[i]) && !Char.IsWhiteSpace(Text[i])) { IsCapital = true; } if (IsCapital) { if (Char.IsUpper(Text[i]) || Char.IsLower(Text[i])) { IsVowel = true; } else { NumberOfWords++; IsCapital = false; } } } return NumberOfWords; } } } Thanks! A: You can have only one return type for a function. If you have to return multiple values, then you have to use out parameters For example: public static void Main(string[] args) { var result = convertWordAndSentence(text); } static int convertWordAndSentence(string text) { int numberOfWords = 0; int numberOfSentences = 0; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (Char.IsLetter(c) && !Char.IsWhiteSpace(c)) { if (Char.IsUpper(c) || Char.IsLower(c)) { numberOfWords++; } else { numberOfSentences++; } } } return numberOfWords, numberOfSentences; } Note: You can't return a boolean value as a single return value, since a boolean cannot be converted to any other value, you'll have to choose one of the three available types, namely bool, int or string (The last one is the easiest) EDIT: In your case you'll have to make use of out parameters as @Guffa suggested in the comments: static void Main(string[] args) { Console.Write("Enter a sentence: "); string Sentence = Console.ReadLine(); var result = convertSentence(Sentence); } static int convertSentence(string text, out int NumberOfSentences, out int NumberOfWords) { int length = text.Length; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (Char.IsLetter(c) && !Char.IsWhiteSpace(c)) { if (Char.IsUpper(c) || Char.IsLower(c)) { NumberOfWords++; } else { NumberOfSentences++; } } else { break; } } return NumberOfSentences, NumberOfWords; } This will return the number of words and number of sentences, but as you want to return both at the same time, you'll have to use out parameters as mentioned above. And yes, you can return multiple values. And even if the return type of a function is void, you can still return a value. For example: static void Main(string[] args) { Console.Write("Enter a sentence: "); string Sentence = Console.ReadLine(); var result = convertSentence(Sentence); int numOfWords = result.Item1; int numOfSentences = result.Item2; } static IEnumerable convertSentence(string text) { // ...... code ..... return result; } Or, you can use a local variable and return it: static void Main(string[] args) { Console.Write("Enter a sentence: "); string Sentence = Console.ReadLine(); var result = convertSentence(Sentence); } static int convertSentence(string text) { int numberOfWords = 0; int numberOfSentences = 0; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (Char.IsLetter(c) && !Char.IsWhiteSpace(c)) { if (Char.IsUpper(c) || Char.IsLower(c)) { numberOfWords++; } else { numberOfSentences++; } } else { break; } } return numberOfWords, numberOfSentences; }