C
C#4mo ago
Yarden

✅ I'm trying to work with Timer class but something doesn't work properly..

I'm following "Bob Tabor" course in Microsoft channel. I'm following him step by step, but it seems like what works for him doesn't work anymore, maybe C# update took a part in the past? It doesn't detect the Timer object in line 11 for some reason, what is wrong? Bob Tabor did it exactly this way. Around 07:20:00 in this video: https://www.youtube.com/watch?v=0QUgvfuKvWU&t=25421s
Microsoft Developer
YouTube
C# Fundamentals for Beginners
Check out the new Foundational C# Certification by freeCodeCamp: https://aka.ms/csharp-certification Classic Throwback Series with Bob Tabor | Originally published in 2019 Install the latest version of Visual Studio at https://visualstudio.microsoft.com/?WT_mc_id=dotnet-58793-cxa and follow along at home too. C# is a powerful and widely used p...
No description
31 Replies
ACiDCA7
ACiDCA74mo ago
if you hover with the mouse over timer does it say ambigous reference? or when you try to compile what are the errors?
Yarden
YardenOP4mo ago
yep
No description
ACiDCA7
ACiDCA74mo ago
as the message says timer exists in system.timers and system.threading.. remove one of the namespace imports since threading seems unused i would guess that one
Yarden
YardenOP4mo ago
And if I used both? How can I avoid it? And thank you very much\
ACiDCA7
ACiDCA74mo ago
you would have to either create a alias or be more specific when using eg instead of Timer you would have to write system.threading.timer
Yarden
YardenOP4mo ago
Still have the same issue after deleting the threading
No description
ACiDCA7
ACiDCA74mo ago
is it in global usings?
Yarden
YardenOP4mo ago
what do you mean "global using"?
ACiDCA7
ACiDCA74mo ago
to not always have to import the same namespaces there are global usings that you define just once and have access to in the whole project
Yarden
YardenOP4mo ago
aa so yes ofcourse I wrote on the top: using System.Timers;
ACiDCA7
ACiDCA74mo ago
naah thats not what i mean ;) gimme a sec
Yarden
YardenOP4mo ago
No description
Yarden
YardenOP4mo ago
Oh okie Sorry 🙏
ACiDCA7
ACiDCA74mo ago
rightclick the project then properties then in the settings on the left side there should be a tab globals usings. is that setting on or off? or alternatively open the csproj in a texteditor and search for ImplicitUsings
Yarden
YardenOP4mo ago
That's what I have
No description
Yarden
YardenOP4mo ago
aa wait on the class I guess i found this global, 1 sec
Yarden
YardenOP4mo ago
seems like on?
No description
ACiDCA7
ACiDCA74mo ago
yeah turn it off for new devs thats always a trap -.-
Yarden
YardenOP4mo ago
Thank you! May I know what exactly it does please? Because it sees like Console.ReadLine() doesn't work now?
ACiDCA7
ACiDCA74mo ago
like i wrote before these using are globally available, so you dont have to add these using yourself in every class, but like in your case can clash with other namespaces that you define locally. for console.writeline just add using System; at the top of the file
No description
ACiDCA7
ACiDCA74mo ago
No description
Yarden
YardenOP4mo ago
already have 😶
No description
ACiDCA7
ACiDCA74mo ago
aehm did you rebuild the project? seems to me like you were making changes to the code while debugging
Yarden
YardenOP4mo ago
Yeah but not now, I did it few hours ago
ACiDCA7
ACiDCA74mo ago
try now.. does it give any errors?
Yarden
YardenOP4mo ago
To try to do "Rebuild" you mean?
ACiDCA7
ACiDCA74mo ago
jea
Yarden
YardenOP4mo ago
yep helped!! thank you much much ❤️ Other problems appeared but this works at least 😂
ACiDCA7
ACiDCA74mo ago
when you dont understand why visual studio is adding squigglies under something, always hover over it first and see what VS has to say.. it would have told you ;)
Yarden
YardenOP4mo ago
Oh yeah, but it's really confusing Too many words I'm not sure about I believe I will get better with time. Just want to tell you thank you very much, you helped tons, and as it seems, everything works properly ❤️
ACiDCA7
ACiDCA74mo ago
np

Did you find this page helpful?