The only way to code!
IntelliSense is a general term for various code editing features including: code completion, parameter info, quick info, and member lists. IntelliSense features are sometimes called by other names such as "code completion", "content assist", and "code hinting."
I assume most of you have used a word process like Word before. So you know that when there is an error or simply a warning of some sort you get a red, blue or other coloured line under the offending word or phrase.
Visual Studio and any IDE (Integrated Development Environment) worth using will do the same thing with your code. And just like Word and other word processors if you simply right click on that offending word or phrase it will offer various suggestions for fixing the problem.
IntelliSense can do a lot more for you though than simply correct basic coding errors. Its also able to identify missing
usingstatements, incorrect name formatting, logic errors such as reference comparisons and even stub out code for you.
Heathen is not affiliated this is simply a video that might help those who don't want to read
So you where told to register a handler on some event, but how are you supposed to know what parameters that event needs to work?
Well actually as your typing IntelliSense will tell you what kind
That means its an action that takes a paramiter of type string, but don't worry you don't need to read.
Type the name you want for the handler even though it doesn't exist yet.
Now we have our lovely little red line telling us hay ... this doesn't exist. You can now follow the steps as we have done for every other use case and be presented with several solutions.
The top solution will be to create a new private method suitable for this event handler. Which I have done and you can see the results below.
If you have ever gotten sample code from me then you know I misspell a lot of things.
How could you possibly know what it should be ... well aside from being better at spelling than me? Use IntelliSense! + a little bit of reading ... its a lot I know but we can do it!
Right click `Initalized`
Click "Quick Actions and Refactorings"
Select the best option. Notice it gives you 4 options
- Generate property
SteamSettings.InitalizedThis will create a new property in SteamSettings named Initalized of type bool ... handy if I was trying to create a new property but nope I just cant spell so I don't want to do this
- Generate field
SteamSettings.InitalizedThis will create a new field in SteamSettings named Initalized of type bool ... again handy if I was trying to create a new field but nope I just cant spell so I don't want to do this
- Generate read-only field
SteamSettings.InitalizedAgain no, I am not creating a field of any kind
InitializedYes ... that's it I just forgot to add that second
inow it will work!
So we want the 4th option, which is to correct my bad spelling
So your copy and pasting some sample code form Discord or somewhere else but one of the objects say
SteamSettingsis giving you a red line, its not found. How can you possibly know how to fix this?
Right click SteamSettings
Click "Quick Actions and Refactorings"
Click the solution!
Now there may be multiple solutions, mouse over each to see what it will do for you. In 99% of cases the top solution is the best solution.
Having done so you can see that it has added the namespace I was missing for me and my error is now gone.
So you where told to call the XXXX method on some object or class, but it requires parameters how are you supposed to know what they are and what they mean?
IntelliSense actually tells you what they are and what they mean as you start typing. See in the screen shot above it has listed all the parameters showing there data type. As I go to enter each one it will show me the code documentation for each parameter.
For the first paramiter I can see its of type
Steamworks.ELobbyTypeand given the coloring I can see that is an enum.
In fact as I type the opening pram bracket It highlights the enum for me
So I can simply press "Tab" or "Enter" to accept that suggestion and use that enum. I can also see what the enum does based on the documentation. note in the screen shot
type: The type and visibility of this lobby. This can be changed later via SetLobbyType.
So I know what this param does.
So when I am done with param 1 I press
,as you do in C# to move on to the next paramiter and IntelliSense will show me the code documentation and provide suggestions for the next parameter
Here its saying
maxMembers: The maximum number of players that can join this lobby. This can not be above 250
So I know I can type a number here, and the suggestions it will feed me will be any numbers or objects that contain numbers that might fit here.
So you where told there is a field or something in XXXX that should help ... the person helping you didn't know the name just that it was there ... so can you use that to help your self?
Yes of course you can, IntelliSense will show you all the members of an object, what they are and what the code documentation says about them.
Lets say you where told that you can find a list of your Achievements on the Steam Settings object but they aren't sure what the list is called.
Start typing, we know its in SteamSettings so lets start there.
And the moment we press the
.as you do in C# to access the properties of an object we are presented with a list of all the members of this object. This list is also smart, so it will take into account the context you are in and what you have recently used and high light that first. I can keep typing if I need to and it will start filtering that list based on the letters I am typing.
In this case Achievements is at the top of the list and I can see from the comment on it
The list of achievements registered for this application
That its exactly what I was looking for so I am done!