I need to write a program that will total the integer values of each characters in a string not including spaces. The program should produce two totals. First should be a fixed string, second should using an empty string of 80 charact. max lenght, using both alphanumeric and numeric characters. I'am fresh in this so please help me. Can you give me any clue!?
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
public static void Main(string[] args)
{
string str = " The quick red fox jumped over the lazy brown dog";
string str1 = "My mother will finish 40 years soon";
int liczba = str.Remove(' ').Length;
int liczba1 = str1.Length;
int totalcount = 0;
int totalcount1 = 0;
foreach (char ch in str)
totalcount++;
Console.WriteLine(" There are {0} characters in strig:\n{1}\n", liczba.ToString(), str);
foreach (char a in str1)
if (Char.IsDigit(a))
totalcount1++;
Console.WriteLine(" There are {0} characters in strig:\n{1}", liczba1.ToString(), str1);
Console.WriteLine(" Oh no a digit" + " has been found ");
}
}
I don't know how to count in the second sentence, how many characters there are without spaces. When I put: int liczba1 = str1.Remove(' ').Length; the program can't build solution.Thanks