Im learning C Sharp

Started by Hardcoal, September 19, 2021, 14:19:38

Previous topic - Next topic

Hardcoal

And I must say it makes me miss Blitzmax..
Im learning it for unity..

Its so inconvenient from Editing Aspect, but I guess I have to get used to it. I have to move on
Code

Pfaber11

I am having a go at learning Python as a second language . My usual is AGK studio and I have come to really like it over the last couple of years .
What it takes me hours to do in an unfamiliar language I can do in minutes in AGK and it is a joy to use . Really wish AGK would  become mainstream but I don't see that happening for quite some time and it probably never will. Good luck with c# .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Qube

If you are in the process of learning C# for Unity the make sure you're using Visual Studio or Visual Studio Code with the Unity plugins. Visual Studio Community edition works better the VS Code does so I would recommend that.

You may find it best to skip doing anything with Unity initially and build up some basics in C# alone like loops, if statements, arrays, functions etc as a lot of basic game coding will involve the basics over anything super advanced. You'll find the Unity API is massive and very daunting at first with pretty wordy commands.

The fundamentals of C# are pretty easy to pick up but it's the Unity API which will suck your time up.
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Hardcoal

The thing is when i work with blitz max.. my lines are very slim..
in c sharp you want to make an If condition it goes..

IF (blahblah)
{
     Code Blah blah
}

it takes one more line..  but generally it occupies more area on my screen.. so i cant see lots of code at once..


BTW Python suppose to be almost like basic.. and rather cool..

But each language is trying to out smart the other by anther method of enclosing conditions..

I think in python you dont even close an If condition

Mark Sibley Is a genius and he done exactly how a language should be!
he should get awarded a noble prize for that.

but we live in a dumb word. so i dont expect that to happen

Code

iWasAdam

erm...

IF (blahblah){
     Code Blah blah
}



IF (blahblah){  Code Blah blah  }

iWasAdam

Quote from: iWasAdam on September 20, 2021, 08:24:40
erm...

IF (blahblah){
     Code Blah blah
}



IF (blahblah){  Code Blah blah  }


not sure on this one but...

IF (blahblah)  Code Blah blah

[/quote]

Hardcoal

yea  i know it can be done in one line.. thats not the point..
i said when its not done in one line it become too long..

also in microsoft visual studio the gaps between each line are huge .
maybe it can be set.. ill check it..
but on default it sucks
Code

Kronos

#7
Personally I find the for loops that use Range in Python a bit unintuitive.

For x in range(6):
     print(x)


plus range is actually 0-5.

For x = 0 to 5 works pretty well for most languages and its obvious what the values are.

Unfortunately C# is a lot more verbose but you can autofill some of it. (i think typing for and then pressing tab twice in visual studio)

for(int i = 0;i<6;i++){
   do stuff
}


ps
to follow up IWasAdams comment you can do this in C# where the then bit is one line(no curly brackets)

if(x==y)
   do stuff;





Steve Elliott

#8
I personally don't like the C Style for loop, it's ugly and less clear than BASIC's straightforward and clear version IMO:



BASIC:

for i = 0 to 9

with a modern twist I'd like:

for int i = 0 to 9



The problem with C-based optional block symbols { } is it can lead to bugs if code is added to a single line statement later and the user forgets to add the block statements - because only the next line will be executed.

Like in Kronos' example:


if( x == y )
    do stuff;

if( x == y )
    do stuff;
    add do more stuff;    // won't get executed as intended


As for Python, well having to ensure every line is on an exact column; what could possibly go wrong?   ::)
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Pfaber11

Yes indeed the Python indentation rules  can go to shit sometimes it happened to me the other day .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Aurel [banned]

python sucks..it is slow

modern twist ..that just mean that variable i (should be)is local to for loop.
(Y)

Steve Elliott

Yes older versions of BASIC weren't known for local specification of data types, more modern languages usually do - but I still prefer the general syntax of the BASIC for loop - all-be-it with a data type prefix.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb