Can i program in C# rather than C?

Hello everyone, this is my first post and i'm honestly 100% new to Arduino! I just came back from the store from purchasing a 27$ Arduino Uno! I'm extremely stoked and excited to begin using it. I have basic understanding of electronics. However, as i was reading and getting a bit more familiar with arduino, i realize that most projects are coded in C. My question is, must i be familiar with C before i begin looking at projects to recreate? Or can i simply code in C# which is what i'm based of (Taking C# classes, i'm much more familiar with it). If so were and how can i code it? Is there a specific Arduino setting that i must use for it to recognize that its been coded in C# over C Programming? i'd appreciate this noob question, any help is appreciate and well i'm extremely glad to be part of the Arduino Community! Thank You!

I'm pretty sure that the Arduino IDE is only going to let you use C or C++. I think the Netduino uses Visual Studio and C#, but I'm not positive.

Aww really? That's such a bummer, oh well! Would you recommend me learning c++ or C? I've heard that C++ is literally used for a ton of things over C. I rather use C++ because well i eventually will need it! However, i want your opinion on whether i should or not. Also whats the level between switching over from C# to C++, in terms of difficulties? Thanks for all the help!

Just jump in & do it. I didn't know any C++ before I started Arduino-ing - and some argue I still don't based on my code posts :slight_smile: - but it just seemed like fancy BASIC with extra ; and () and {} to me.
Functions-macros-objects-classes-libraries - yeah, if you say so!

I agree with CrossRoads. I've taught C, C++, and C# and I really do like the environment Visual Studio provides, and it supports all three languages. However, the Arduino IDE doesn't use C#, so I'd put that on the back burner for now as far as Arduino work goes. If you already know Object Oriented Programming (OOP), C++ shouldn't be too tough. If you don't know OOP, you might master C and ease into C++, since you can get a lot of stuff done with the Arduino with just straight C, and I think it's easier to learn if you don't have OOP experience. You'll find it similar to C# in terms of its syntax.

There are plenty of free tutorials on line for both languages. Since you're taking a C# class now, you should be learning OOP and that should make learning C and C++ pretty easy. If you want some help from books, I've written texts on C (Beginning C for Arduino) and C# (Beginning OOP with C#), but that's hardly an unbiased recommendation! There are a ton of choices.

I don't know C#, but isn't it a flavor of C++ anyway? You can write in C++ if you just read and hack a few examples. There is no need at the moment to use the OOP aspect of C++. Straight function calls will get you very long way.

I don't know C#, but isn't it a flavor of C++ anyway? You can write in C++ if you just read and hack a few examples. There is no need at the moment to use the OOP aspect of C++. Straight function calls will get you very long way.

I've barely touched C#, but it seems like you only use classes, as in only the object orientated aspects you find in C++.
To do a straight function call, you need to use a static class function. It seems like it wraps whatever it is ported to in a bunch of namespaces and classes. You could mimic this style in C++ by using objects for everything or even an API like Cosa.

C# == I Can't Believe It's Not Java

Other than syntactic idioms, C# and C++ are very much alike. AWOL probably has it right: C# was Microsoft's answer to java before Oracle took it over. Microsoft takes a lot of hits, many of them deserved, but C# in their IDE is a nice environment in which to teach and learn. I, for one, miss their debugger and have played with Visual Micro on more than one occasion. As far as the OP goes, he should finish his C# class and absorb as much OOP as possible, using C in the Arduino IDE in the meantime. If the time comes where OOP makes sense for an Arduino project, the C# programming class he's taking and whatever C experience he picks up on his own, should allow him to transition to C++.

AWOL probably has it right

You misspelled “definitely”.

C# was Microsoft’s answer to java

You misspelled “ripoff of”.

Other than that, I agree with you. Except for the part about the IDE and a nice environment.

C# == I Can't Believe It's Not Java

Surely it can't be that bad?


@PaulS: Going to have to disagree with you on this one. Visual Studio is a nice environment in which to teach and learn any of its supported languages. I taught programming using everything from the editor-compiler-assembler-linker days to VS and, as far as a student learning something, the VS environment let me spend more time teaching the language rather than the steps necessary to move from editor to EXE. The only downside of the VS enviroment is that students tend to use the "throw-this-at-the-bug-and-see-if-it-works" approach to program development and debugging. It was a lot different when you had a 6" stack of IBM cards, had to walk a half-mile to submit it for compilation, get a job number passed back through a little slot in the wall, call on the phone to see which job numbers were ready, walk back over to get it, only to find the comma in column 70 should be in column 71. Students don't seem to learn a disciplined way to debug a program. Throw a stray pointer at them and they go comatose.