First of all I would like to thank the forum unlimited times for writing to my difficulties every time I post---- is there any way to thank the members other than this?
Now my DIFFICULTY here
there is a doubt regarding the use of arrays;
step1 ) We may define an array as:-
int[] arra ;
step2 ) We would initialize it as:-
arra= new int[4] // say
step3i ) or in a single step as:-
int[] arra = new int[4];
or
step3ii )
int[] arra = new int[4]{45,5,78,2};
Now there is a piece of code .
//Here we would the Reverse() method of the array type in string
static class Helpers
{
public static string Reverse(string s)
{
char[] characters = s.ToCharArray();
// what this ABOVE step does in relation to the steps written above?
// Does it create a STACK or a MANAGED HEAP?
Array.Reverse(characters);
// are we initializing the array in the step BELOW
what makes you ask your question?; specifically have you executed your code?
Two things you can do to find out what your code does ...
(a) run it in LINQPad 4*
(b) create a console application in vs2010 and DEBUG your code.
For small pieces of code like your example in this thread's O.P., i use LINQPad 4 probably 99% of the time.
Please do (a) and/or (b) and let us know what you've learned.
BTW, (b) is also important because it's absolutely essential to know how to use the vs2010 debugger.
g.
* if you do not have LINQPad 4:
TOOLS ... get yourself a FREE copy of LINQPad 4 (http://linqpad.net) .. Joe Albahari's LINQPad 4 is an awesome programmer's scratch pad that enables you to quickly check out code snippets you find in books and on web sites
plus LINQPad also lets you rapidly experiment with c# ideas before committing them to vs2010.
LINQPad 4 supports c#, F#, SQL, vb.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
static class Helpers
{
public static string Reverse(string s)
{
char[] characters = s.ToCharArray();
// what this ABOVE step does in relation to the steps written above?
//this will also initialise the array variable. while in the above cases declarative values were assigned in array... here, the result of s.ToCharArrays will be used.
// Does it create a STACK or a MANAGED HEAP?
//since, the array is getting initizlised, the references array values would be stored in heap
Array.Reverse(characters);
// are we initializing the array in the step BELOW
//no this will initialise string variable (which is again reference type)
return new string(characters);
}
}
hope this helps...
Cheers!
KK
Please mark as Answer if post helps in resolving your issue
My Site
Marked as answer by Dino He - MSFT on Feb 17, 2012 08:32 AM
amigo 1
Member
60 Points
199 Posts
doubt regarding the use of arrays
Feb 07, 2012 12:25 PM|LINK
First of all I would like to thank the forum unlimited times for writing to my difficulties every time I post---- is there any way to thank the members other than this?
Now my DIFFICULTY here
there is a doubt regarding the use of arrays;
step1 ) We may define an array as:-
int[] arra ;
step2 ) We would initialize it as:-
arra= new int[4] // say
step3i ) or in a single step as:-
int[] arra = new int[4];
or
step3ii )
int[] arra = new int[4]{45,5,78,2};
Now there is a piece of code .
//Here we would the Reverse() method of the array type in string
static class Helpers
{
public static string Reverse(string s)
{
char[] characters = s.ToCharArray();
// what this ABOVE step does in relation to the steps written above?
// Does it create a STACK or a MANAGED HEAP?
Array.Reverse(characters);
// are we initializing the array in the step BELOW
return new string(characters);
}
}
please help
gerrylowry
All-Star
20525 Points
5713 Posts
Re: doubt regarding the use of arrays
Feb 07, 2012 02:17 PM|LINK
@ amigo 1
what makes you ask your question?; specifically have you executed your code?
Two things you can do to find out what your code does ...
(a) run it in LINQPad 4*
(b) create a console application in vs2010 and DEBUG your code.
For small pieces of code like your example in this thread's O.P., i use LINQPad 4 probably 99% of the time.
Please do (a) and/or (b) and let us know what you've learned.
BTW, (b) is also important because it's absolutely essential to know how to use the vs2010 debugger.
g.
* if you do not have LINQPad 4:
TOOLS ... get yourself a FREE copy of LINQPad 4 (http://linqpad.net) .. Joe Albahari's LINQPad 4 is an awesome programmer's scratch pad that enables you to quickly check out code snippets you find in books and on web sites plus LINQPad also lets you rapidly experiment with c# ideas before committing them to vs2010.
LINQPad 4 supports c#, F#, SQL, vb.
kedarrkulkar...
All-Star
34545 Points
5554 Posts
Re: doubt regarding the use of arrays
Feb 07, 2012 02:45 PM|LINK
static class Helpers
{
public static string Reverse(string s)
{
char[] characters = s.ToCharArray();
// what this ABOVE step does in relation to the steps written above?
//this will also initialise the array variable. while in the above cases declarative values were assigned in array... here, the result of s.ToCharArrays will be used.
// Does it create a STACK or a MANAGED HEAP?
//since, the array is getting initizlised, the references array values would be stored in heap
Array.Reverse(characters);
// are we initializing the array in the step BELOW
//no this will initialise string variable (which is again reference type)
return new string(characters);
}
}
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site