C
C#4mo ago
Jexs

✅ 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
No description
97 Replies
Jexs
JexsOP4mo ago
i also notice when i type in cw and hit tab it auto types char instead of the entire LOC Console.WriteLine("etc")
leowest
leowest4mo ago
because your code is broken looking at the image above its missing ; and ) and " in previous lines
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
string greeting = " Welcome to Mars "; // missing ;
Console.WriteLine($"[{greeting}]"); // missing );
string greeting = " Welcome to Mars "; // missing ;
Console.WriteLine($"[{greeting}]"); // missing );
on this one I can't see the whole thing to tell but I assume u had something like
Console.WriteLine($".... some stuff ..." +
$".... more stuff ...."); // missing ending " and ;
Console.WriteLine($".... some stuff ..." +
$".... more stuff ...."); // missing ending " and ;
Jexs
JexsOP4mo ago
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); } } } }
leowest
leowest4mo ago
can you post the contents of your project file? You can see it by double clicking it in the solution explorer
No description
leowest
leowest4mo ago
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
Jexs
JexsOP4mo ago
uhhh one sec 😄
Jexs
JexsOP4mo ago
i got it to work btw also @leowest is this what you want to see
No description
leowest
leowest4mo ago
yep just wanted to confirm u were on .net 8 so its all working now?
Jexs
JexsOP4mo ago
Yes god bless you brother 🙂
leowest
leowest4mo ago
$close
MODiX
MODiX4mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Jexs
JexsOP4mo ago
I notice i have the same problem with my new code and i dont see anything wrong
leowest
leowest4mo ago
and what is the new code
Jexs
JexsOP4mo ago
No description
leowest
leowest4mo ago
after the loop add Console.ReadKey();
Jexs
JexsOP4mo ago
same thing D:
Jexs
JexsOP4mo ago
No description
leowest
leowest4mo ago
upper case K
Jexs
JexsOP4mo ago
same
No description
leowest
leowest4mo ago
yep that should work
Jexs
JexsOP4mo ago
let me restart a whole new project thats what worked last time
leowest
leowest4mo ago
how are u doing things? u write code then delete everything and write a new code? you can create many projects inside a solution
leowest
leowest4mo ago
i.e.:
No description
Jexs
JexsOP4mo ago
When the problem ever comes about i just create a new project and copy and paste the code inside the static void main area
leowest
leowest4mo ago
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
Jexs
JexsOP4mo ago
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
leowest
leowest4mo ago
mmm k yeah that wouldn't break it alone
Jexs
JexsOP4mo ago
i know im leaving something out rn but idk what i did do another step but i forgot what it was Dx
leowest
leowest4mo ago
make sure u dont have this
No description
Jexs
JexsOP4mo ago
what a headace to forget
leowest
leowest4mo ago
in the project otherwise if u copy and paste a different namespace it will lose the entry point
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Just this
Jexs
JexsOP4mo ago
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?
leowest
leowest4mo ago
about what?
Jexs
JexsOP4mo ago
in this reply you said not to have this but what do you mean how would i check if i have that or not
leowest
leowest4mo ago
👆
Jexs
JexsOP4mo ago
does coping and pasting the code break it all the time?
leowest
leowest4mo ago
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
Jexs
JexsOP4mo ago
give me one sec to re read chat
leowest
leowest4mo ago
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
Jexs
JexsOP4mo ago
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)
leowest
leowest4mo ago
yes that is the project file
Jexs
JexsOP4mo ago
where it shows .net 8 right?
leowest
leowest4mo ago
yes
Jexs
JexsOP4mo ago
give me one sec
Jexs
JexsOP4mo ago
this is what it currently shows what would a problem case show?
No description
leowest
leowest4mo ago
ah I see
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
u dont have that checked do u
Jexs
JexsOP4mo ago
witch opition do not use top level statements
leowest
leowest4mo ago
yes that is why it adds the rootnamespace for u
Jexs
JexsOP4mo ago
im not sure should i open a new project and repaste the code
leowest
leowest4mo ago
give it a try
Jexs
JexsOP4mo ago
okay
leowest
leowest4mo ago
u will notice the difference
Jexs
JexsOP4mo ago
first screen ops
leowest
leowest4mo ago
also $codegif
Jexs
JexsOP4mo ago
No description
leowest
leowest4mo ago
in the next window
Jexs
JexsOP4mo ago
Next
No description
leowest
leowest4mo ago
check
No description
Jexs
JexsOP4mo ago
Can you explain to me what that means
leowest
leowest4mo ago
it means that instead of an empty file with
Console.WriteLine("Hello World");
Console.WriteLine("Hello World");
u get a file with namespace, class and static main
Jexs
JexsOP4mo ago
oh okay
leowest
leowest4mo ago
that is the difference u would noticed
Jexs
JexsOP4mo ago
and you want to have this checked everytime right when your writing code? or creating a new projject
leowest
leowest4mo ago
no, but apparently you are using and learning with it so its better if u do
Jexs
JexsOP4mo ago
okay
leowest
leowest4mo ago
also u only have to check it once subsequent projects will have it checked by default
Jexs
JexsOP4mo ago
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.....?
leowest
leowest4mo ago
no I asked u to remove it to reduce the possibilities of what could have been the issue
Jexs
JexsOP4mo ago
im so lost buddy im sorry D:
leowest
leowest4mo ago
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.
Jexs
JexsOP4mo ago
okay
leowest
leowest4mo ago
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
MODiX
MODiX4mo ago
* 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 vs
leowest
leowest4mo ago
but I also doubt that would be your issue
Jexs
JexsOP4mo ago
Okay well i guess checking marking this new opition will ease the problem right?
leowest
leowest4mo ago
it will ease you from copying more then u need to
Jexs
JexsOP4mo ago
Okay
leowest
leowest4mo ago
but yeah next time instead of creating a new project try the above
Jexs
JexsOP4mo ago
what is a top level statement btw?
leowest
leowest4mo ago
This is the normal template for a console c#
using System;

namespace Application
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
using System;

namespace Application
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
basically top level statment allows you to skip the namespace, class and static main and lets u write code directly
Console.WriteLine("Hello World!");
Console.WriteLine("Hello World!");
it generates more confusion then needed it was a form they found to make it quicker and similar to python
Jexs
JexsOP4mo ago
wouldnt you need to first declare a namespace (using system) a class area then static void main(string[] args) to even start writing code?
leowest
leowest4mo ago
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
Jexs
JexsOP4mo ago
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
leowest
leowest4mo ago
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive using directive is used to import other libraries into your code
using System;
using System;
Is importing the System library for example.
Jexs
JexsOP4mo ago
Would you consider it boiler plate code
leowest
leowest4mo ago
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.
Jexs
JexsOP4mo ago
Wdym by yesnot?
leowest
leowest4mo ago
its when it can be both things it can be boilerplate in some scenario as much as it wont in other. so "yesnot"
Jexs
JexsOP4mo ago
Oh okay 🙂 Ty
Want results from more Discord servers?
Add your server