|
Yes that is true but it's good to know that 'var' exists.
I find that I'm best at learning programming by studying medium sized programs. I like to step thru a program to see how it works. I also try to write a simple C# program from what I have learnt.
I suspect the biggest thing that turns beginners away from learning C# is when their program is fulled with errors and they have no idea on how to fix the problem or where they went wrong as they have tried to build a complex program before fully learning C#. Jumping in the deep end as they say.
Things like l1.addExit(new Exit(Exit.Directions.North, l2)); takes a bit of getting use to but I'm keen to learn and are starting to understand it more.
Brian
|
|
|
|
|
Brian_TheLion wrote: I suspect the biggest thing that turns beginners away from learning C# is when their program is fulled with errors When I see a student whose code is full of errors (beyond typos), I see a student who is not being guided properly, or, a student who is "flailing" because they have not grounded themselves in language basics, or don't know how to study in a disciplined way.
Once you make some progress in getting over the initial learning curve with C#, I predict you will look back on VB and Python as the messes they are
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Hi Bill.
I hope your right.
You do get some lift of confidence when the program runs without errors.
With me it's a case of getting out of the habit of script coding like I did with Basic and QuickBasic.
Brian
|
|
|
|
|
Thanks Richard for the var info.
Brian
|
|
|
|
|
Thanks for the links and info Richard.
Brian
|
|
|
|
|
Currently I'm using version 2015 if Visual Studio and was wondering if anything happened to my computer and I had to reinstall Visual Studio then would I still be able to install version 2015. I remember that you run a small program that caused it to download and install itself (unless there is a way to download the complete file for storage)
I was told that there were some issues with version 2017 so I'm staying with version 2015 at the moment.
Brian
|
|
|
|
|
Yes, you can: Download Older Visual Studio Software | Visual Studio - Visual Studio[^] and I'd agree that 2017 wasn't good (but neither was 2015 which is why my "revert to" version is 2013)
The latest though - 2019 - seems pretty solid to me so far, and has some very nice bits and bobs.
BUT. If you have several version on your system, then must be installed "earliest first" or they will give problems (MS says so, and my experience in the past bears that out)
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I've been using 2017 for quite a while now and have not come across any issues. Maybe I don't use it enough.
|
|
|
|
|
Maybe it was just the early versions (or an interaction with the other crap on my system) but when I originally installed it, "flaky" was a good word to describe it. Weird UI glitches, disappearing code, crash to desktop, slow as heck - that's why I gave up and went back to 2013.
Glad to hear it didn't affect everybody.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I've found 2017 to be solid; 2019 keeps changing my text editor settings; so much so, I'm staying with 2017.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I have been studying C#. When writing C# code I seem to have three types of code I could use for variables but are not certain when I need to use the code.
I could type this
Code One
<pre>public string Name
{
get;
set;
}</pre>
or I could type
Code Two
<pre>public string Name
{
get
{
return name;
}
set
{
name = value;
}</pre>
or I could type
Code Three
<pre>public void SetLength (double len)
{
length = len
}</pre>
And sometimes Code One and Code Three are used.
I think that one of these codes are used if I make the Variables private instead of public.
Any help would be welcome thanks
Brian
|
|
|
|
|
I'd like to suggest you do some study of what Fields, and Properties, are in C#. Note that in your examples above you never declare variables 'name and 'length.
Start here: [^], [^], [^]. And, listen to Jon Skeet: [^]
Properties are actually a form of Method, technically called an "accessor."
Before auto-properties came along ... in C# 3.0 ... ('set and 'get only), this was a canonical pattern for Properties:
private int _mInt;
public int MInt
{
get { return _mInt; } set { _mInt = value; }
} Now, when you write:
public int MInt { get; set; } The private backing field is created behind the scenes. These two examples are, functionally, identical.
Some basic research and experimenting, now, will really benefit you.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
modified 15-May-19 23:05pm.
|
|
|
|
|
Thanks Bill.
I'm studying some code examples.
Thanks for letting me know about the upgrade in C# causes things to happen in the background. Maybe some code examples are for the older version of C#.
In your reply you said
Start here: [^], [^], [^]. And, listen to Jon Skeet: [^]
I'm, not certain if there was a site address that you wanted me to go to?
Brian
|
|
|
|
|
Each of those ^ links should take you to relevant content ... if they're broken, let me know.
May I suggest re-framing your concern from "Selecting the correct code" to getting a good grasp of C# language fundamentals so that, in the future, you can make wise choices about what semantics and structures to use ?
You have the possibility of 'static variables, as well, and, the options for access: 'public, 'private, 'protected, 'internal.
C# is a very rich, and deep, language: for better, and worse, there are multiple ways to implement many fundamental structures, and relationships.
cheers, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Hi Bill.
I'm trying to get a good understanding of C# and these are some of the things that beginners to C$ have trouble with but I'm hoping that the more I study the code and try writing some small programs of my own then everything should fall into place.
I'm more use to using Basic (in the past) which had global variables.
Brian
|
|
|
|
|
A combination of study, and coding small-scale examples that use the information and concepts you are studying, is an excellent way to learn.
You can search CodeProject to find books that I, and other people, have recommended. This one is free (in English): [^] ... [^]
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Thanks Bill for the useful links. Lots of useful information at these links.
Brian
|
|
|
|
|
When you use <pre> tags, please make sure you select the correct language from the dropdown list that appears when you click the code button above the edit box. And also make sure that the checkbox marked "Treat my content as plain text, not as HTML" below the edit box, is unchecked.
|
|
|
|
|
I was told I need to add a tag at the start or end of my code so it is formatted correctly when posting code on this discussion group. I've forgotten what the tag is.
Can someone please tell me.
|
|
|
|
|
PRE tags. You can just highlight was you pasted in and hit the "code" button just about the Message box.
|
|
|
|
|
|
I've tried multiple c# programs that I've found on the web, including this one from Code Project:
.NET Wrapper for ChangeDisplaySettingsEX[^]
I'm not sure why but I've never been able to successfully change my secondary display. NOt sure what I'm missing? Can someone provide any insight?
|
|
|
|
|
Try sharing your code so we can see what you are missing?
|
|
|
|
|
Message Removed
modified 14-May-19 11:59am.
|
|
|
|
|
Message Removed
modified 14-May-19 11:59am.
|
|
|
|