✅ Why wont my intella sence work
i declared a string ModifiedGreeting and when i go to type it out it doesnt pop up in intella sence as a declared variable as a fast type opition when hitting tab
97 Replies
i also notice when i type in cw and hit tab it auto types char instead of the entire LOC Console.WriteLine("etc")
because your code is broken looking at the image above its missing ; and ) and " in previous lines
on this one I can't see the whole thing to tell but I assume u had something like
I fixed the errors in my code and still dont see it showing up when i hit the play button using System;
namespace MyApp
{
internal class Program
{
static void Main(string[] args)
{
string fName = "john Bert";
string ffName = "Jose florez";
Console.WriteLine($"both {fName} {lName} and Traveled to mars and the first" +
$"thing they saw was the mars Welcome Sign that said... ");
string Greeting = " Welcome to Mars ";
Console.WriteLine($"[{greeting}]");
string ModifiedGreeting = Greeting.TrimStart();
Console.WriteLine($"[{ModifiedGreeting}]");
ModifiedGreeting = Greeting.TrimEnd();
Console.WriteLine($"[{ModifiedGreeting}");
ModifiedGreeting = Greeting.Trim();
Console.WriteLine($"[{ModifiedGreeting}");
Console.WriteLine($"As they read this sign they also wanted their Names to be edged into the " + $"eletronic tablets {fName} had a total of {fName.Length} and {ffName} had a total of " + $"{ffName.Length} Characters in his name witch was to short so knowing they couldn't " + $"they decided to leave once the count down started they knew they could stay to long"); for (int i = 10; x > 0; i++) { Console.WriteLine("Second left to closing enterence " + i); } } } }
Console.WriteLine($"As they read this sign they also wanted their Names to be edged into the " + $"eletronic tablets {fName} had a total of {fName.Length} and {ffName} had a total of " + $"{ffName.Length} Characters in his name witch was to short so knowing they couldn't " + $"they decided to leave once the count down started they knew they could stay to long"); for (int i = 10; x > 0; i++) { Console.WriteLine("Second left to closing enterence " + i); } } } }
can you post the contents of your project file? You can see it by double clicking it in the solution explorer
also u have an error in your for loop
x > 0 should have been i > 0 and instead of i++ u want i-- if u want to make it a countdown
uhhh one sec 😄
i got it to work btw also @leowest is this what you want to see
yep just wanted to confirm u were on .net 8
so its all working now?
Yes god bless you brother 🙂
$close
If you have no further questions, please use /close to mark the forum thread as answered
I notice i have the same problem with my new code and i dont see anything wrong
and what is the new code
after the loop add Console.ReadKey();
same thing D:
upper case K
same
yep that should work
let me restart a whole new project
thats what worked last time
how are u doing things?
u write code then delete everything and write a new code?
you can create many projects inside a solution
i.e.:
When the problem ever comes about i just create a new project and copy and paste the code inside the static void main area
sure but how are u doing things? before the problem happens
because I see 2 problems
one is that you're losing auto complete and intellisense
the other is that ur code is not running as if u were changing more than just the static main
so i open up a new template then i follow the default link and copy and paste the code witch is this
using System;
namespace MyApp
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
and then i just start coding
mmm k yeah that wouldn't break it alone
i know im leaving something out rn but idk what
i did do another step
but i forgot what it was Dx
make sure u dont have this
what a headace to forget
in the project
otherwise if u copy and paste a different namespace
it will lose the entry point
Just this
can you explain to me in dept a bit more im still kinda confused and im also taking notes too
so for my note sake and my sake can you be in more dept?
about what?
in this reply you said not to have this but what do you mean how would i check if i have that or not
👆
does coping and pasting the code break it all the time?
by opening your project file
that line is not common to have
so it was added there somehow
I can only assume
no it shouldn't break I have not tested but excluding possibilities
give me one sec to re read chat
when you create a new console project, that line is not present, so its not part of the template to create a new console project
so you said make sure i dont have that do you mean make sure i dont have that in the area where i double click my project area (like you asked me before too)
yes
that is the project file
where it shows .net 8 right?
yes
give me one sec
this is what it currently shows what would a problem case show?
ah I see
u dont have that checked
do u
witch opition do not use top level statements
yes
that is why it adds the rootnamespace for u
im not sure should i open a new project and repaste the code
give it a try
okay
u will notice the difference
first screen
ops
also $codegif
in the next window
Next
check
Can you explain to me what that means
it means that instead of an empty file with
u get a file with namespace, class and static main
oh okay
that is the difference u would noticed
and you want to have this checked everytime right when your writing code?
or creating a new projject
no, but apparently you are using and learning with it
so its better if u do
okay
also u only have to check it once
subsequent projects will have it checked by default
So for my notes sake:
The error that i made by copying and pasting code was the project file (the project sdk code ) got modified because.....?
no
I asked u to remove it to reduce the possibilities of what could have been the issue
im so lost buddy im sorry D:
ok so for your notes sake, there has been nothing said so far that pin point what is causing your issue
I dont have enough information to know it.
okay
all the information u have provided does not equate to breaking those things
unless you're doing something u haven't said in here I dont see anything that would break it
sometimes vs gets drunk and does weird things which can usually be solved with $vsdrunk
* close VS
* remove the hidden folder
.vs
* remove all bin
and obj
folder next to each csproj (DO NOT TOUCH THE .git
FOLDER OR WHAT'S INSIDE)
* restart vsbut I also doubt that would be your issue
Okay well i guess checking marking this new opition will ease the problem right?
it will ease you from copying more then u need to
Okay
but yeah next time instead of creating a new project try the above
what is a top level statement btw?
This is the normal template for a console c#
basically top level statment allows you to skip the namespace, class and static main
and lets u write code directly
it generates more confusion then needed
it was a form they found to make it quicker and similar to python
wouldnt you need to first declare a namespace (using system) a class area then static void main(string[] args) to even start writing code?
using adds a library to your project
namespace declares a namespace
yes the first code I posted is the usual code
but with top level statement the compiler generates that code for u behind the scenes
so when u run or compile or build your app it will actually generate all those
https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/top-level-statements
Okay
I think thats all for now 😄 ty for your help buddy much apperiated !
what is this called
using system;
is that a namespace?
@leowest
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive
using directive is used to import other libraries into your code
Is importing the System library for example.
Would you consider it boiler plate code
yesnot
it facilitates things in many ways but it doesnt necessarily mean you will be reusing it everywhere
but yes it does go into the "don't reinvent the wheel"
.net is this massive ecosystem, that gives you all kind of libraries to empower your tasks which can be used by the languages it supports c# being one of those.
so you have libraries for tcp, sockets, math, encryption, and list goes on.
Wdym by yesnot?
its when it can be both things
it can be boilerplate in some scenario as much as it wont in other.
so "yesnot"
Oh okay 🙂
Ty