|
humdumof wrote: What happen to value i stored in abc during class B, does It got restore to default by C class obj creation.
No, the instance of A that is created in the B class is separate from the instance of A created in the C class.
humdumof wrote: What is the scope of variables declare at class level, as soon as control comes out from a class does they restore to default?
At the class level, you have to distinguish between class members (static variables) and instance members (member variables). A static variable in a class exists only once and exists in the class rather than in an instance of the class. A member variable exists in an instance of the class, so it's separate for each instance. A member variable retains it's value as long as the instance exists.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: A member variable exists in an instance of the class, so it's separate for each instance. A member variable retains it's value as long as the instance exists.
class test
{
string abc = "";
}
class Test2
{
test t1 = new test();
t1.abc = "some value";
test t2 = new test();
t2.abc = "next value";
}
Does it means as long as t1 exist(not garbage collected), t1.abc =="some value" ?
Means t1 is seprate & t2 is seprate copy?
Is it correct?
What i thought, suppose there exist A, B, C classes.
set the class A feild within B, then i was trying to access that value(which i set in B) in C by another obj created inside C.
We cant set like this, can we?
modified on Wednesday, June 11, 2008 5:55 AM
|
|
|
|
|
humdumof wrote: Does it means as long as t1 exist(not garbage collected), t1.abc =="some value" ?
..if you don't change the value
humdumof wrote:
Means t1 is seprate & t2 is seprate copy?
Is it correct?
t1 and t2 are different instance of Type test, yes.
|
|
|
|
|
humdumof wrote: Means t1 is seprate & t2 is seprate copy?
Is it correct?
Yes.
humdumof wrote: What i thought, suppose there exist A, B, C classes.
set the class A feild within B, then i was trying to access that value(which i set in B) in C by another obj created inside C.
We cant set like this, can we?
No, you can't. They are separate instances, and they are not aware of each other.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks a lot for your replies.
|
|
|
|
|
How to reverse the string by the following manner ?
If string is "This is the test".
1] Reverse string should be "tset eht si siht"
2] other one: "siht si eht tset" (for this, using substring function)
|
|
|
|
|
Homework ?
We won't help you; You have to do it yourself. We can help you when you are struck somewhere.
|
|
|
|
|
How abt a loop which iterates the length times of the given string and stores the values from the last char index to first in another string
Try it once if u struck post code
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
string result = myString == "This is the test"?"tset eht si siht":"siht si eht tset".SubString(0,16);
That should do it, 100% according to your spec
|
|
|
|
|
With some logic thinking you can use the String.ToCharArray(); and the rest I leave up to you...
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
I don't normally help with homework but today I'm feeling generous:
public string ReverseString1(string s)
{
return "tset eht si siht";
}
public string ReverseString2(string s)
{
return "siht si eht tset";
}
|
|
|
|
|
First, we never support code solicitations here. But there is a proven saying that the lotus flower grows only in marshy pond. You seem to prove this saying by initiating a brainstorming topic of 'XOR in C#' through a gibberish post.
Here goes the topic:
http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|
|
|
VS 2005 ? Cristal Report?
Have Fun
Never forget it
|
|
|
|
|
VS2008, MS Reporting services ... but thanks I came right
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
AFAIK you need to select a table. Did you try all the idiot options?
|
|
|
|
|
leppie wrote: Did you try all the idiot options?
Yes, I came right .... thanks
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
we implement all methods from the interface, then why should interface required ?
|
|
|
|
|
My suggestion would be to get a good book of Object oriented concepts and programming and read it first.
This will answer your all questions.
One of many benefits of interface is that it allows us to implement multiple inheritance
You can find more about interface, if you read about it in book or search on Google to read online tutorials.
-Ajay.
-------------------------
www.componentone.com
-------------------------
|
|
|
|
|
Ajay K. Singh wrote: One of many benefits of interface is that it allows us to implement multiple inheritance
This is not correct.
C# doesn't support multiple inheritance (MH).
A class doens't inherit the behaviour of the interfance, because an interface doesn't have an implementation.
A class can Implement the methods declared in an interface. It is allowed to implement multiple interfaces. But that is NOT inheritance. It simulates MH it at the cost of re-implementation of every method that is declared.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
I agree that Interface simulates the multiple inheritance behavior.
-Ajay.
-------------------------
www.componentone.com
-------------------------
|
|
|
|
|
Ajay K. Singh wrote: I agree that Interface simulates the multiple inheritance behavior
What behaviour? interfaces have no behaviour because they have no implementation.
|
|
|
|
|
The interface is like a contract. If a class implements an interface, you know that it fulfills the contract. Then you can also use the object in the form of the interface instead of the form of the class.
This is very useful with classes that implement the same interface. For example, both a string array and a List<string> implement the IEnumerable<string> interface. You can make a method that takes an IEnumerable<string> as parameter, and you can send either a string array or a List<string> to the method, so that the method can loop through the collection without caring about what the collection really is.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Wednesday, June 11, 2008 8:11 AM
|
|
|
|
|
Hi,
In overriding the method why method name should be same ?
|
|
|
|
|
Hi,
See here[^], I think it will help.
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|