Status
Not open for further replies.
lemme try help. You pair with all your long words making things all hard to understand and telling him to read 500 page books :/

The reason you declare it twice in that instance is because you are creating an instance of that object. lemme show you. practical ftw.
Here are a few ways of declaring stuff.

PHP:
// Create an array
object myObject = new object[] {"hello", "one", "two", 3};

// Create a string from an object
string myString = (string)myObject[1];

// int from object
int myInt = (int)myObject[3];
string myLength = (string)myObject.Length
So basically you see that things dont have to be what they once were. Almost everything can be converted to something else. So its not always "object myObject = new object" - sometimes its like the ones in the example.
 
yep.

e.g.

u have an array called "bob" - u can get the size of the array by using .Length - same for strings yes.

e.g.

PHP:
string[] myString = new string {"one", "two", "three", "four" };

// SIZE of array (in this example, would return "3")
int size = myString.Length;

// LENGTH of string within the array (in this case, would return "5")
int size = myString[2].Length;
 
Jay why do you have to declare as string

string[] myString = new string {"one", "two", "three", "four" };

should it not be

array[] myArray = new array {"one", "two", "three", "four" };

??
 
what if it was a mixture of strings and integers ? sorry if there stupid questions !

Again, forget you know PHP. An array can, or better: should, contain only one type. Not mixed. The reason you can mix them in php is because it's a dynamic language. It doesn't use types. A CPU works with types too so that's why all major programming language work with types. Types are everything.

The only thing you should remember from PHP is if-else, switch, etc. The basics. Everything else is not gonna apply to C# because PHP is not a real programming language.

Edit:
Having said that I should add that even though I know all of this is a bit confusing for you right now. The important thing is to bite the bullet. After a month or 2 you'll have a much better understanding of it. I started out with HTML, PHP, JS etc and moved to C# later on. I've been trough the same transition :). Also, C# is one of the easier languages out there :).
 
yeah i did give a bad example. What i did with the object is kinda bad, you shouldnt really use an object like i did, but tbh, i know the outcome, which is why i am happy to use them like that.
 
Status
Not open for further replies.
Back
Top