Как вернуть значение в классе - C#
Формулировка задачи:
Листинг программы
- class Class1
- {
- public static string Counter(string s)
- {
- char[] punct = { ',', '.', '?', '!' };
- string str = @"af,asdf.asdf?asdf!sdfsdfg'";
- s = str;
- string l = new string(punct);
- for (int i = 0; i < str.Length; i++)
- {
- for (int j = 0; j < l.Length; j++)
- {
- if (str[i] == l[j])
- {
- return str[i];
- }
- }
- }
- }
- }
Решение задачи: «Как вернуть значение в классе»
textual
Листинг программы
- public static string Counter(string s)
- {
- char[] punct = { ',', '.', '?', '!' };
- string res="";
- for (int i = 0; i < s.Length; i++)
- {
- for (int j = 0; j < punct.Length; j++)
- {
- if (s[i] == punct[j])
- {
- res+=s[i]+" ";
- }
- }
- }
- return res;
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д