|
how to use Google?
how to use MSDN
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
public class a<br />
{<br />
public void aaa()<br />
{<br />
}<br />
}<br />
public class b<br />
{<br />
public void abc()<br />
{<br />
a aa;<br />
aa = new a();<br />
b bb;<br />
bb = new b();<br />
object a1 = aa;<br />
bb = (aa)a1;
bb = (a)a1;
<br />
<br />
}<br />
}<br />
This is the code i was trying to call the function of class a from the object of class b.
I am not being able to understand how can i do that , using the boxing - unboxing concepts.
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Sonia Gupta wrote: bb = (aa)a1; //error
//The type or namespace name 'aa' could not be found
bb = (a)a1;//Error Cannot implicitly convert type 'a' to 'b'
1. aa is not a class or type, it's an object
2. Class a is not sub class of class b. Totally unrelated.
|
|
|
|
|
so how i should call the funciton of class a from the object of class b
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Sonia Gupta wrote: so how i should call the funciton of class a from the object of class b
By using a reference to an instance of class a.
If class b would inherit the class a, you would be able to call it directly in class b.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Sometimes we need to convert ValueTypes to Reference Types also known as boxing.In your case You are trying to convert an object into another type of object..... This is not the concept of Boxing and Unboxing. Objects are of reference types so you can convert them using type casting. May this help you out otherwise reply me..
|
|
|
|
|
can u please improve my code.i mean , hoq i can call the function of class A using the object of class B
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
define an object type variable and then cast it into A type only then you will be able to use it through casting. Otherwise if I try to explain you through an example then you are trying to cast sachin tendulkar to Irfaan pathan and its not possible.(a and b class are different you cant cast one into another.)
I suggest you,Please do some google and you will find the answer of your question. otherwise reply me....
|
|
|
|
|
int i = 0, j = 0;
i++;
j = ++i;
in the above code , specially in the last line,i am thinking that the variable j will get the value first , then valiable i will get the value.
and normally the execution goes from right to left.But in this case of prefix the exexcution goes from left to right
Am it Right?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
J will get the value only after completion of ++i. for example if i is 2 and j is 0,now you use j=++i then first i will get the value of 3 then j will become 3.
here is difference in prefix and postfix:-
The postfix version usually involves a construction of an extra copy of the object, in which its state is preserved, whereas the prefix version is applied directly to its object.
|
|
|
|
|
Sonia Gupta wrote: j = ++i;
in the above code , specially in the last line,i am thinking that the variable j will get the value first , then valiable i will get the value.
No, that's not correct. First the variable i is incremented, then the new value of i is assigned to the j variable.
Sonia Gupta wrote: and normally the execution goes from right to left.But in this case of prefix the exexcution goes from left to right
No, in an assigment the value is always calculated before it's assigned to the variable.
Consider this statement:
j = i++;
First the variable i is incremented, then the previuos value of i is assigned to the j variable. The value of the expression i++ is the previous value of the variable, although the variable is incremented before the value of the expression is used.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Thanks.....
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
What's the meaning of primitive type here?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
your statement is wrong.
Primitive types datatypes are basic system defined data types.It includes Object and string also and both are reference type.
and if you look at Value type, the value type variables directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined (structs), or enumerations (enums).
|
|
|
|
|
why are u asking so many basic questions that u can answer urslef by reading a book on C#
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Presumably they're homework questions, and actually learning the subject matter would be too much effort.
|
|
|
|
|
yes why put soo much effort when u have CP
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
i am declaring two classes
class A
{
virtual void abc()
{
}
}
class B:A
{
override void abc()
{
}
}
now i create an object for both the classes
A d = new A();
B e =new B();
d.abc();
or
e.abc();
in case of e.abc() abc() function is of class A or B
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
|
What is this?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Hi all,
I had 2 tab.
each tab had a table and a update btn.
User after updating the cell in the table. he will press the update btn before pressing the other tab.
it is possible tat?
everytime the user updated the cell, and he press the tab, the application will promote him to press the update 1st?
how was it done with the coding?
this are the call event.
private void dgScore_CellEndEdit(object sender, DataGridViewCellEventArgs e)
private void tabMain_SelectedIndexChanged(object sender, EventArgs e)
any other event I can use to make it possible?
|
|
|
|
|
I suggest you should change the interface model. Basically tab control is not meant to work like that. It might be possible to use it that way but it would definately be v confusing for the user.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Is there a way to cancel the event to change tab?
So it will remain at the same page.
|
|
|
|
|
Hi,
I have a Datagrid in my windows form to which i am entering data like name,roll no.,class...its working fine.but when i close this window and reopen it i cannot find the date that i have entered.
I want the data grid to display the previous data also everytime when i enter the new data
the form looks like this::
DATAGRID
Textboxes ot enter values
Upgrade button
How can i do this......
Requesting help.
Thanking You
C#
|
|
|
|
|
Did u use data base for it
Happy Programming
-----
Abhijit
|
|
|
|