|
Spunky Coder wrote: i was taught that both in java and c# objects are referenced types so when we do any operations on the object they get reflected to entire object wherever you access it
But you are not doing any operation on object, you are changing the reference itself.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Spunky Coder wrote: The above still gives the output as "Grade1Employee" why is it so?
You're passing a reference to a Manager object to the method. If you change the object via this reference the changes reflect outside the method (first example). If you create a new object and assign the reference to it to the method parameter, then this change does not reflect outside the method (second example), because changes to parameters (values or references) do not reflect outside a method unless you use the ref or out keyword.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
When you take (Manager man) as input, you are actually taking a copy of the pointer to the actual manager. that means it points to the same object, but you cannot change the pointer adress declared in main, to do that you need the ref.. dunno if you get what i mean tho, im not good at explaining ^^
Manager man <- pointer to a manager object
= new Manager() <- returns adress to the new object
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
|
|
|
|
|
Suppose we alter the first example as following...
public static void changevalue(Manager man)
{
man.name = "Grade1Employee";
man = null;
}
still the emp.name in the main function gives the value "Grade1Employee"....Now when we are assigning a value to the member of the object (to the reference copy of the object) , the value is retained and when are setting the reference copy to null the value is not retained....
Koushik
|
|
|
|
|
hello all!
i have a dataGridView that i add a context menu to each row when adding the row:
dataGridViewOrder.Rows.Add(itemRow);
dataGridViewOrder.Rows[dataGridViewOrder.Rows.Count - 2].ContextMenuStrip = contextMenuStripProducts;
on run time, if i left click the row then right click it and choose the menu, every think is ok.
but i have a problem when the currentRow is for exemple the first row, and i right click another row, it appear the menu of the second row but the changes made for the CurrentRow are applyed for the first Row, because it is the CurrentRow.
i was tryed to set the currentRow on mouse down event but a compilation error say that currentRow is read only...
please if some one have a solution or an idea for this problem, tell me about it.
thank u all!
regards.
jimmy.
jim MAA
|
|
|
|
|
You can use the CurrentCell property to set (or get) the currently selected cell.
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
Hi,
Is there any way i can get a list of items i want added to a ToolStripMenu from SQL.
I have a database which contains records that i enter using the application im developing.
However, i want to be able to use the SELECT DISTINCT SQL command, to retrieve the names of something from a column, and put it into my toolstrip.
Is there any way of doing this?
Id be grateful of anybodys help
|
|
|
|
|
why don't you create the control when the sql load completed?
|
|
|
|
|
|
Create a function call "GenerateToolStripMenu()" or something, when you filled the data to the dataset, fire the function.
e.g.
for (int i = 0; i < database1DataSet.Table1.Rows.Count; i++)
{
menuStrip1.Items.Add(database1DataSet.Table1.Rows[i][%your_column_name_here%].ToString());
}
|
|
|
|
|
Hello everyone,
I am using C# to develop DLL using Visual Studio 2005 and .Net 2.0, and I have no idea of how to make my DLL work with applications on 64-bit platform. Above all, I do not utilize any new features in my DLL of 64-bit. So, I want to check the general rules,
1. For C#, is there a need to make two separate builds (32-bit and 64-bit) according to the application (32-bit or 64-bit) which uses the DLL? i.e. provide 64-bit application my 64-bit C# DLL, and provide 32-bit application runs on 64-bit platform my 32-bit DLL?
2. If we have to make two separate builds, how to do it in Visual Studio 2005? I only find a setting names for Any CPU in project --> properties.
thanks in advance,
George
|
|
|
|
|
I had the same questions, and got some great advice in the .Net forum which was:
1. Yes you can choose to target x86 and x64 processors individually. Doing so requires that you have two builds. Alternatively, you can choose the Any CPU option, which will run on both.
2. From: http://blogs.msdn.com/tolong/archive/2007/03/21/use-visual-studio-to-build-64-bit-application.aspx[^]
To configure your projects target on 64-bit platform, you can utilize the configuration manager on visual studio.
Here are the steps:
1. Go to Build menu
2. Select Configuration Manager
3. In the Active solution platform list, select the 64-bit platform for the solution to target.
4. If you do not see the option, select New
5. In the New Solution Platform dialog box, select the 64-bit platform for the solution to target.
6. Now the build of the project will be optimized for 64-bit platforms.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
hi,
in c language we use \n for nextline
but what is the method of nextline in c#.
textBox1.Text = "A";
textBox1.Text += "B";
i want
A
B
not AB
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
Erhm, you can still use the \n and \r characters, but what would be better is :
<br />
Environment.NewLine<br />
|
|
|
|
|
Use the Environment.NewLine property. It gives you the proper character combination depending on the platform that the code is running on.
---
"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
|
|
|
|
|
but how i can use Environment.NewLine
what would be updation on following code
textBox1.Text += "A";<br />
textBox1.Text += "B";
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
textBox1.Text += Environment.NewLine;<br />
textBox1.Text += "A";
Is it right?
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
zeeShan anSari wrote: Is it right?
Did you try it? Did it work?
|
|
|
|
|
ya
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
Hello,
I have never used the printing functionality in C#.
I am having a data grid which is having 3 colums. I want to print one column out of three and some more custom data with this column. I want to print the data in tabular form with some header lines like "Name", "Date" etc.
How do i print in C#.
Thank a lot in advance.
-- modified at 5:50 Friday 19th October, 2007
|
|
|
|
|
|
Let's have a look at the datagrid print code i am writing......
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
int iHorzResolution = e.PageSettings.PrinterResolution.X;
int iVertResolution = e.PageSettings.PrinterResolution.Y;
int iPaperWidth = e.PageSettings.PaperSize.Width;
int iPaperHeight = e.PageSettings.PaperSize.Height;
int iWidthPixel = iPaperWidth * iHorzResolution/100;
int iHeightPixel = iPaperHeight * iVertResolution/100;
PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics, new Rectangle(new Point(0, 0), new Size(iWidthPixel, iHeightPixel)));
this.InvokePaint(datgrdSerialNumber, myPaintArgs);
}
private void btnPrint_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
Now if i fire the print command, i am not getting the size of of grid accroding to my page(A4). It just prints the grid in left corner. Where am i going wrong???
Thanks.
|
|
|
|
|
Hellow, ho do i can to prevent removing row from DataTable. I.e. when row are being removed
by user, i need to validate this action and only after this remove this row or cancel this if neccessary.
I can't use RowDeleteing event because this one can't prevent row deletion if needed, such as only way to do this (as i know) is throw an exception and catch one by myself. But in my code i can't controle exception what throw my DataTable.
Thank.
|
|
|
|
|
Extend base datatable creating a new event on datarow remove
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
Could someone please help me with this loop I'm working on.
The goal is to end up with a list of rar-files to be deleted after unpacking.
I have a list of the first rar-files in the span and I want to get the rest.
For the new-style rar-files, I figured I remove the ".rar" and ".part" from the filename
and just add one number higher, but that doesn't work since there are zeros to account for.
For the old-style rar-files I'm even more lost since there are booth zeros and letters added.
I know the letters are added one higher but I can't figure out a good way to do it.
This is what I've got now:
"rarsToDelete" contains the first rar-files in span
"rarSpanList" should contain the rest of the files in the end
private void DeleteRarFiles()<br />
{<br />
if(rarsToDelete != null)<br />
{<br />
ArrayList rarSpanList = new ArrayList();<br />
foreach (string s in rarsToDelete)<br />
{<br />
string fileNoExt = s.ToLower().Substring(0, s.LastIndexOf(".")-1);<br />
if(fileNoExt.EndsWith(".part1"))<br />
{<br />
string fileNoExtNoPart = fileNoExt.Substring(0, s.LastIndexOf(".") - 1);<br />
int i=2;<br />
string testFile = fileNoExtNoPart + "part" + i;<br />
while (File.Exists(fileNoExtNoPart + "part" + i))<br />
{<br />
rarSpanList.Add(testFile);<br />
i++;<br />
}<br />
<br />
}<br />
else if(File.Exists(fileNoExt+".r00"))<br />
{<br />
<br />
}<br />
}<br />
}<br />
}
Thanks
|
|
|
|