|
Hi,
How can I get a deep copy of an array of classes? The class implements ICloneable, and when I try to get a deep copy of it when it's not in an array it works fine:
class A : ICloneable
{..........}
A aa=new A();
A bb=(A) aa.Clone();
but if I have an array of classes it doesn't:
A[] arrA=new A[3];
//init the array here
A[] arrB=(A[]) arrA.Clone(); //this gives me a shallow copy
One way to do it is to explicitelly clone each element:
A[] arrB=new A[3];
for (int i=0;i<3;i++)
arrB[i]=(A) arrA[i].Clone();
Is this the best way to do this? Thanx!
|
|
|
|
|
The Clone method always creates a shallow copy. If you want a deep copy you have to clone each object.
---
b { font-weight: normal; }
|
|
|
|
|
What is the best solution for displaying on a web page page a
collection of records where each record is to be conditionally
tested and then displayed with formatting based on the conditions within each record.
Example: A series of 50 records is retrieved from database consisting
of a company name, company phone number and state. Also included in
each record is a season code. Task is to display the company name,
state and conditionally display the phone number.
In cases where the records season code matches a predefined value the company name will appear in bold type and the phone number will display.
Do any of the .net 2.0 data controls allow you to conditionally format
the appearance of record components as they are written to the
webpage?
Thank you,
antar007
|
|
|
|
|
I have a question that I hope somebody has figured out. Visual Studio 2005 is definately a productive environment, that goes without saying, but there are a occasionally annoyances that you wonder what they were thinking.
My annoyance question is how do you cause double-click to "View Code" in solution explorer rather than "View Designer". I have been using the environment for about three years now and I can't and I still can't get used to this being the default option.
Its not that it is such a big deal in and of itself but I am forever double-clicking to edit the code and then I get the designer that I didn't want, which I have to close and then reopen the same node with "View Code".
Double click is instinctive for open so I don't use the buttons.
Is there a way to change the option to open in "View Code" when double clicking? I (like most probably) have a 10:1 ratio of editing code versus UI. There are times you want to edit the forms/controls, of course, but, that is the exception.
Anyone know a way to change this? Is it possible?
Thanks,
Jim
|
|
|
|
|
It's possible to set up the preferences to view code and not designer for web pages, perhaps that option is in there as well. I am quite used to right clicking and hitting 'view code', tho. You can also set the solution explorer to show the .cs file under the designer file like a tree view, then you can select the file you want and double click on it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
I don't see a place to do that with the C# editor. So its obvious that Microsoft realizes there a is a preference between the code/design views. Double clicking has always opened CPP files, including dialog and control files in the old VS's. Of course they were separated in those days. It was a good idea to integrate them into Solution Explorer. I am hoping there is a registry settings or something if not comprehended in the Options. I figure it was an oversight.
Of course this is not "earth-shattering", I mean all you have to do is right click and navigate down the menu, its just an annoyance when you are deep in concentration.
Jim
|
|
|
|
|
Show all files is in the solution explorer, but while that helps for ASP.NET, it doesn't seem to help for winforms. Perhaps there isn't a way ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You just may be right. Bummer...
|
|
|
|
|
Try opening the .csproj file in a text editor, you will see that it's an xml file. All compilable .cs files are included inside COMPILE tags. If you expand this tag you can modify it such that it looks something like this:
<Compile Include="MainForm.cs">
<SubType>Code</SubType><code> or </code><SubType>Designer</SubType>
</Compile> This may do what you want, but I've had occasions where VS has overwritten the changes I've made.
TIP: It's quite nice if you've got partial classes to group them as VS does for Forms etc, just add the <DependentUpon>MainFile.cs</DependentUpon> tag inside the Compile tag and voila you have all partial classes underneath the main node of representing the class in Solution Explorer
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Ed,
These are good suggestions. What you have illustrated is what I wanted. The only problem is that VS 2005 converts them on open so that they are whatever type it can recognize from the file's internal data. If it sees the InitializeComponent then it converts it to a component.
But that would probably do what I am looking to do.
Thanks for the suggestions.
Jim
|
|
|
|
|
I was thinking of writing an add-in which would allow this but I don't have a copy of VS so I can't . Maybe in a few months if I buy a copy
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
AOA
I want the help that how i can generate runs in C# for perform external sorting. In advance thanx
abbas ali
|
|
|
|
|
I think that you have to be a bit less vague in your question.
What is it that you want to sort? In what way should the sorting be external?
---
b { font-weight: normal; }
|
|
|
|
|
I want to sort the records which can not reside in the RAM there for i want that i get the chunks of the records and then sort them and in the end merge all these sorted runs.
abbas ali
|
|
|
|
|
I'm starting to get a picture... What you might be looking for is merge sort; an algorithm used when computers had so litte RAM that all data resided in files, and sorting had to be done by sorting small chunks into separate files and then merging the small sorted files into a single sorted file.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
We can loop through collection using foreach and IEnumerator.Can any body help
me when to use foreach and when to use Ienumerator since both will loop through collection and get the result?
|
|
|
|
|
foreach uses the IEnumerator retrieved from GetEnumerator() on an object that implements IEnumerable . So, foreach is using IEnumerator internally anyway.
|
|
|
|
|
Hi, I am currently suffering the limitations of the listbox control, I would really like to have a generic listbox, rather than the default of using objects.
It would also be really useful if I could make a custom listbox and override the functions "Items.Add" and "Items.Remove", but I can't work out how to override these functions.
I am not sure if these things are even possible, I haven't been able to find out much about them googling the web, can anyone point me in the right direction?
thanks
|
|
|
|
|
Martin23 wrote: like to have a generic listbox,
Do you mean you'd like to be able to add string s? If so, you can. (A string is nothing but a System.Object ).
/ravi
|
|
|
|
|
i am calling a function thats reads a text file but the strange thing is that it only reads two files at a time
this fucntion calls the reader function
while((this.fromdateDT.Equals(this.todateDT))!=tru e)
{
day=Convert.ToString(this.fromdateDT.Day);
month=Convert.ToString(this.fromdateDT.Month);
year=Convert.ToString(this.fromdateDT.Year);
temp=year+"-"+month+"-"+day;
this.fileName=this.pathString+"smdrbackup"+temp+". csv";
try
{
this.runReader(this.fileName);
}
catch
{
}
this.fromdateDT=this.fromdateDT.AddDays(1);
}
runReader is the function that reads the file
the code snipet that does the reading here in that function is
Stream str= File.Open(CSVpath,FileMode.Open, FileAccess.Read,FileShare.ReadWrite);
StreamReader sr;
sr= new StreamReader(str);
but if say for example it is suppose to read the following files: k2006-10-12,k2006-10-13,k2006-10-14,k2006-10-15. it reads the first two and say the last two do not exist. but they do and if i skip out the first two and have k2006-10-14,k2006-10-15,k2006-10-16 it once again only reads the first two even though in another order it said it could not find them.
so basically its only accessing two files after that it says every other fiel does not exist.................anyone have had a problem like this
kenny
|
|
|
|
|
My bet would be on the while loop's termination condition.
keroed_edmond wrote: while((this.fromdateDT.Equals(this.todateDT))!=tru e)
{
Did you try stepping your code through the debugger and checking if the loop runs more than two times?
|
|
|
|
|
hi all
this is what i plan to impliment. create a media server with some videos. develop an application to select the file and view it. i would be implimenting it on my college network. i do not plan to use media streaming.
i would need help on the following:
1. how do i get the media player up and running? does it have the functions to connect to the database and fetch the file?
2. whats the best way to impliment the database. should i keep an index in a databse like SQL or access?
regards
Vineet
|
|
|
|
|
I develope project for secondary school and I
need answer for my question...
How to make beckup for the database from my project?
waleed alkali
student
|
|
|
|
|
hi
i made a ToolStrip and placed it in a ToolstripContaier.
but i want it to be able to float. it is just stuck in the ToolStripContainer and doesnt float when i drag it out of container.
|
|
|
|
|
ASAIK the ToolStrip doesn't support this as standard, you might be able to write an extended version of it. Failing that there are several toolbar controls around which support this, Divelements[^] for one has a very good one (although not free anymore).
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|