❔ error CS1525: Unexpected symbol `String'
using System;
public String DuplicateCount(string input)
{
foreach (char a in input) { int i = a.Count; if (i > 1){ Console.WriteLine($"{a}:{i}");} }
} DuplicateCount("indivisibilities"); why doesn't this work?
foreach (char a in input) { int i = a.Count; if (i > 1){ Console.WriteLine($"{a}:{i}");} }
} DuplicateCount("indivisibilities"); why doesn't this work?
13 Replies
a.Count is invalid
yes, but that's not the main problem here
somehow String on line 3 isn't recognised
what is line 3
public String DuplicateCount(string input)
well the other error is that your method does not have a return
good point, im new to this so i forgot
if you were using visual studio, it would have pointed those out for u
what IDE are you using
online, vs code is being weird, doesn't wanna run.
ah well I suggest u use visual studio community instead
its really helpful while learning
so what are you trying to do here
are u trying to skip the first letter?
Servator#3472
REPL Result: Success
Console Output
Compile: 810.352ms | Execution: 103.783ms | React with ❌ to remove this embed.
ah yeah silly me should have read the method name
so yeah what you want to do is, you might want to have a Dictionary to hold the char and count as you iterate in your loop and add to the dictionary and then loop thru the dictionary where your Value is bigger than one
a is a char so you can't use Count like that which is why its invalid
oh
this is what i am trying to do tho thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.