You are viewing our Forum Archives. To view or take place in current topics click here.
[C#] Post your code snippets here!
Posted:

[C#] Post your code snippets here!Posted:

CodeRobbo
  • New Member
Status: Offline
Joined: Feb 22, 201113Year Member
Posts: 4
Reputation Power: 0
Status: Offline
Joined: Feb 22, 201113Year Member
Posts: 4
Reputation Power: 0
Basically I am taking the step which some people wonder on, switching from VB - C#!

Therefore I am in need of some basic codes, from message box - login!

Give me what you have please guys I will be very thankful, hopefully I'll be able to stick it out on C# I know all the benefits it's just getting into it all I guess...

Anyway thanks for your time, Robbo.
#2. Posted:
Derp
  • TTG Senior
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Nice to see some people switch.

Well, anyway, in C#, you need to tell the computer what it execute by doing this

private void button1_Click (EventArgs, e)
{
*PUT YOUR CODE HERE*
}




And, at the end of every statement, you put a ';' so the computer knows when to stop.
A message Box would look like this.

private void button1_Click (EventArgs, e)
{
   MessageBox.Show("i_r_Trolling is the best!");
}


Hope I helped.
#3. Posted:
Experiment5X
  • TTG Senior
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
I have like 19 C# tuts on my channel [ Register or Signin to view external links. ] .

But here are some code snippets:

In C#, instead of using things like "then" and "end if" you use {}

So an if statement would look something like this:

if (textBox1.Text == "")
{
    button1.Enabled = false;
    MessageBox.Show("You need to input text in order to continue!", "Error");
}


And when creating new things like variables or BinaryWriters, you don't use "Dim"
It would look like this:


string myString = "Hello World.";
OpenFileDialog ofd = new OpenFileDialog(); //that "formula" works for all those


Hope that helped
#4. Posted:
Derp
  • TTG Senior
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Also, in declaring shizzle, in VB you would use Dim.
In C# it looks like this.


OpenFileDialog ofd = new OpenFileDialog();
#5. Posted:
RDCA
  • TTG Contender
Status: Offline
Joined: Jul 12, 201014Year Member
Posts: 3,612
Reputation Power: 173
Status: Offline
Joined: Jul 12, 201014Year Member
Posts: 3,612
Reputation Power: 173
Well you shouldn't even learn c# if you already know vb.net. You should move onto a harder langauge that would benifit you a lot more like c++ or lua or some non .net dependency language.
#6. Posted:
Derp
  • TTG Senior
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
RDCAx wrote Well you shouldn't even learn c# if you already know vb.net. You should move onto a harder langauge that would benifit you a lot more like c++ or lua or some non .net dependency language.


Actually, C# is a very good switch from VB, as it helps to understand more about how C Programming works.
#7. Posted:
RDCA
  • TTG Contender
Status: Offline
Joined: Jul 12, 201014Year Member
Posts: 3,612
Reputation Power: 173
Status: Offline
Joined: Jul 12, 201014Year Member
Posts: 3,612
Reputation Power: 173
i_r_Trolling wrote
RDCAx wrote Well you shouldn't even learn c# if you already know vb.net. You should move onto a harder langauge that would benifit you a lot more like c++ or lua or some non .net dependency language.


Actually, C# is a very good switch from VB, as it helps to understand more about how C Programming works.
Its more of a waste of time. Your supposed to chose a beginner language then move onto something harder, not onto something of the same skill level.
#8. Posted:
Derp
  • TTG Senior
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
RDCAx wrote
i_r_Trolling wrote
RDCAx wrote Well you shouldn't even learn c# if you already know vb.net. You should move onto a harder langauge that would benifit you a lot more like c++ or lua or some non .net dependency language.


Actually, C# is a very good switch from VB, as it helps to understand more about how C Programming works.
Its more of a waste of time. Your supposed to chose a beginner language then move onto something harder, not onto something of the same skill level.


Actually, C# isnt the same skill level. C Programming is a lot more harder than VB and C#, C++ evolves off of the C Programming language. And how are you 'suppose' to pick a harder language? You can pick what ever feels better to learn. In my opinion, and a lot of others opinion, C# is a very good move as it will help you if you decide to learn C++.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.