|
Have a look at this[^] entry in wikipedia.
|
|
|
|
|
|
Eslam Afifi wrote: class A
{
}
class B : A
{
}
in the following code
A obja;
B objb = new B();
obja = objb; // boxing
B objc = (B)obja; // unboxing
Wrong!
Boxing does not happen with instances of classes.
|
|
|
|
|
|
Boxing is copying a value type (C# struct) to a reference object in the heap.
Unboxing is copying a boxed object in the heap back to the stack.
Not just primitive value types:
struct S : ISomeInterface
{
...
}
// boxing
S s1 = new S() ;
object x = s1 ; // S instance is created on the stack, then copied to the heap.
ISomeInterface is = s1 ; // This is also boxing
...
S s = (S)x ; // This is unboxing, for unboxing you must use the cast syntax.
Value types are not always placed on the stack, they are inline into it's container. They might be already on the heap, for instance if they are array elements.
S[] a = ...
a[i] = (S)x ;
Boxed value is copied from the heap to the stack and then copied into a[i].
|
|
|
|
|
Hi all!
I have added a combobox control in the datagrid. I want to restrict user to select the value which is already selected in the datagrid.....
Thanx for ur help in advance!!!!
|
|
|
|
|
|
i made a skydome for my model using xna and it displays very well. but for some computers, it doesn't show. is it something wrong with my coding or the hardware?
|
|
|
|
|
Sounds that way...
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I need to know the license in which a software could have at the end
In some applications you see many expressions about that ,would any descibe me or
give me a link to that?
Thnaks
|
|
|
|
|
Pooya Musavi wrote: give me a link to that?
Clickety[^]
/ravi
|
|
|
|
|
I am very new to this. I am trying to remove duplicates from a string.
string str="a badb ce b";
I want the return to "a bdce"
I think we will need two for loops
for (int i=0; i<str.lenght; i++)<br="" mode="hold">{
for (int j=i+1;j<str.length;j++)>
{
}
}
Is this approach correct? I haven't been able to proceed. please help.
Tina_K
|
|
|
|
|
This should put you on the right path:
create the string to be returned;
foreach (character in the original string) {
if (the character doesn't exist in the string to be returned) {
add it to the string to be returned;
}
} /ravi
|
|
|
|
|
As Ravi said.
string oldstr = "a badb ce b";
StringBuilder newstr = new StringBuilder();
for (int i = 0; i < oldstr.Length; i++)
if (newstr.ToString().IndexOf(oldstr[i]) == -1)
newstr.Append(oldstr[i]);
Eslam Afifi
|
|
|
|
|
I creat a new Thread object ,then I call SetApartmentState(ApartmentState.STA).
After this ,when this thread start ,does the Windows will treat this Thread as a Process ? If not ,what's the differcence between ApartmentState.MTA thread and ApartmentState.STA thread?
thanks.
¦¦?¦?¦¦
¦?????¦
¦¦?¦?¦¦
¦?????¦
¦¦?¦?¦¦
|
|
|
|
|
This[^] link may provide an answer.
/ravi
|
|
|
|
|
I have created a class called BankAccount. the samle is a floows
public delegate void myEventDelegate();
class BankAccount
{
public static long Balance;
public event myEventDelegate myEvent;
public void WithDraw(long amount)
{
Balance -= amount;
myEvent();
}
}
i then wired my event in the frm load to an event handler "OnWithdraw"
i also a textbox where by i subtract the money to be withdrawn from the account. The method display an event to the user when the account bal < 0;
when i run the program i receiven a NullArgumentException error on the "myEvent" int BankAccount class
how do i make my event work?
|
|
|
|
|
You should never call a delegate without firstchecking if it is null.
Obviously your event wiring code is broken. You need to post it for us to comment further. Have you checked in the debugger that it gets wired up ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sorry for that. this is my first time posting.
//From BankAccount.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Delegates_and_Events
{
public delegate void myEventDelegate();
class BankAccount
{
public static long Balance;
public event myEventDelegate myEvent;
public void WithDraw(long amount)
{
Balance -= amount;
myEvent();
}
}
}
//from frmMain.cs
private void Form1_Load(object sender, EventArgs e)
{
BankAccount myAcc = new BankAccount();
BankAccount.Balance = 1000;
myAcc.myEvent += new myEventDelegate(OnWithDraw);
}
public void OnWithDraw()
{
if (BankAccount.Balance < 0)
{
MessageBox.Show("Account Overdrawn");
}
}
I also have a textbox where i am getting the value which i subtract using the following
private void btnWithDraw_Click(object sender, EventArgs e)
{
BankAccount myAcc = new BankAccount();
myAcc.WithDraw(long.Parse(txtAmount.Text));
txtBankBalance.Text = BankAccount.Balance.ToString();
}
|
|
|
|
|
I am trying to import a dbase file in to sql . but when an empty record comes the programme stops reading
when empty record comes first , program does not read the table at all.
i use the following connection string
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBFpath + ";Extended Properties=dBase III
rkherath
|
|
|
|
|
Hello Friends,
I am developing C#.NET windows application i want that what ever font size i select from combobox the size of the font changed to that size..
And also according to the font size the size of the control also resized...
Please help me...
Bye
Thanks in Advance
|
|
|
|
|
The easiest way is to set the AutoSize property to resize the control automatically when the text size changes and set the Font property of the control to the font you desire.
button1.Font = new Font("Arial", 18);
Eslam Afifi
|
|
|
|
|
hi
i have process.StartI("projet1.mpp") in my code
sometimes this code run successfully and run the msp projects
but sometimes this code contain error
in trace code process is null and i dont know thats reason
can any one tell me thats reason and its solution?
thanks alot
modified on Monday, February 18, 2008 11:58 PM
|
|
|
|
|
Hello everyone.
At first you might be thinking so what is the big deal in implementing paging.
But actually its not that simple. Here is what i have to implement.
The main parent window where the user gets the records in a datagrid based on dates params in the following format
email - firstName - lastName
By click on email a pop up window displays the detail of that record. Its the same concept as master detail.
Ok now here is the tricky part. i want to have a prev and next button in the pop up window.
So the user can move back and forth to see next or previous record in the pop up window with out closing the pop up and then clicking on the next record in the main parent window to see the detail.
Any Ideas
Thx
|
|
|
|
|
You can use a delegate to get the next id from the main window in your popup.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|