|
Why did I get such a message
"UsingArray.ArrayClass' cannot inherit from special class 'System.Array'?"
I use .Net 2003. Thank you in advance.
Nuray
|
|
|
|
|
Well shoot. It's not sealed, but apparently you're not allowed to derive from it. I found the following text on MSDN describing this.
The Array class is the base class for language implementations that support arrays. However, only the system and compilers can derive explicitly from the Array class. Users should use the array constructs provided by the language.
I'm afraid you are going to have to wrap it.
|
|
|
|
|
public class ArrayClass : System.Collections.ArrayList
{
//
};
This works as suggested by Robert Rohde
|
|
|
|
|
Sounds good. I actually prefer ArrayLists over Arrays myself.
Just be aware that ArrayList is a different class with different methods than Array. It's more like the C++ STL vector class than an array. It'll allocate memory in chunks and more than it needs in order to keep the number of memory allocations low.
|
|
|
|
|
What do you mean by "ArrayLists over Arrays" ?
Could you also read my message to Robert Rohde.
Nuray
|
|
|
|
|
All I'm saying is that the ArrayList class and the Array class are not the same thing. Although feature wise they are similar, they have different functions.
The ArrayList is a data structure that allows you to Add and Remove objects to it. It has more capabilities. An Array has a fixed size.
|
|
|
|
|
OK. I see the difference I need I more advice for complex multidimensional array operations like multiplications, divisions etc. Could you read also my email to R. Rohde?
Nuray
|
|
|
|
|
Hi Nuray,
What Robert suggests is a good idea. However, it forces you to use its built in collection accessable at CollectionBase.List() which doesn't sound like it'll work for you.
Since you said you need a "complex multidimensional array", then I suggest that you create your own Collection class from scratch and implement the ICollection and IEnumerable interfaces. This way you can add your own data structure within it. It's quite easy to make. You should look at the existing collection classes' methods as an example. I actually prefer to make my own collection class anyways because I can control which data structure it'll contain such as an ArrayList, HashTable, Queue, etc.
|
|
|
|
|
Inherit from BaseCollection. It implements much of the common fucntionalities and you just have to add some typesafe versions of Add, Remove, this[int index] etc.
|
|
|
|
|
public class ArrayClass : System.Collections.ArrayList
{
//
};
This works. my ArrayClass inherits from System.Collections.ArrayList
The problem is that I loose control over a single array like GetValue function.
Robert Rohde wrote: you just have to add some typesafe versions of Add, Remove, this[int index] etc.
What do you mean?
ArrayClass myArr = new ArrayClass();
myArr.Add("Nur") ;
This works.
|
|
|
|
|
I said CollectionBase not ArrayList. I mean something like this:
public class MyCollection : CollectionBase {
public void Add(MyItem item){
base.InnerList.Add(item);
}
public void Remove(MyItem item){
base.InnerList.Remove(item);
}
public MyItem this[int index]{
get { (MyItem)return base.InnerList[index]; }
}
}
Now you have a typesafe collection where you can be sure that all contained elements are of type MyItem.
|
|
|
|
|
I got it.
I need one more advice. Built in classes in .NET, to my knowledge, don't provide methods for array operations like multiplication, summation, division etc. I used to handle these by operator overlaoding in a class while using C++.
It seems that I can use Collectionbase for storing arrays. But how about complex array operations?
Thank you in advance.
Nuray
|
|
|
|
|
Hello All,
I'm trying to find a way to check the value of the System Idle Timer and also a way to reset it but havent found any good examples on this can someone toss me a snippet??? please
Michelle
|
|
|
|
|
Hello all,
I am using a foreign dll to read some data out of a certain file. The
problem is: This dll somehow doesn't release the file once you open it
to read the content with the dll.
So after reading the data out of a file it is blocked for write-access
until I completely close my whole application.
My question is: How can I release these files?
What I already tried:
- setting all involved objects null
- calling the GC manually
- simply waiting some time hoping that .NET will release the file
Nothing helped.
Any ideas?
Best regards,
Bertram Weckmann
Development Team
G10 Software AG
www.svizzer.com
|
|
|
|
|
Does code in the DLL that reads from the file call Dispose? If not, then you have no choice but to force garbage collection and finalization, with code like
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Unfortunately I do not know what the DLL exactly does. But anyway, I already tried using the GC with no success. Even with the WaitForPendingFinalizers method. Even with the Marshal.ReleaseCOMObject method...
Any other idea?
|
|
|
|
|
Hello All,
I'm trying to find a way to check the value of the System Idle Timer and also a way to reset it but havent found any good examples on this can someone toss me a snippet??? please
Michelle
|
|
|
|
|
Hi,
My name is Liran, Im working on a project that the server is written in java technology (APACHE TOMCAT) and we considering now to turn the client to windows application instead of web. Our main option is to choose .net c# as our client technology and the connection to the server will be by web services on the server side (the webservices is written in java).
I already made a prototype to check it and it worked really good.
Im trying to get some information about the risks that i need to take into consideration if i choose this option. so if someone already dealt with it ill really appriciate your help.
Best regards,
Liran
|
|
|
|
|
Hello,
I have:
<br />
private void button2_Click_1(object sender, System.EventArgs e)<br />
{<br />
Thread myThread = new Thread(new ThreadStart(starting)); <br />
myThread.ApartmentState = ApartmentState.STA;<br />
myThread.Start(); <br />
}<br />
<br />
private void starting ()<br />
{<br />
Form2 form2 = new Form2();<br />
Application.Run(form2);<br />
}<br />
If I want to pass an argument to the starting method, I have to include an argument when I am starting a new thread, but it complains. Any ideas?
Thank you.
|
|
|
|
|
Unfortunately, the ThreadStart delegate's signature has been defined to take zero parameters, so you're out of luck.
The only way I know of is to use a member variable to pass parameters. Ugly, but it works.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
How can I read Paradox files from C# web application...
Regards
|
|
|
|
|
Hello Dears!
i m working with windows Datetimepicker control i have to save the Starttime and Endtime for a scheduled shift.From fromnt end i did it right by setting the following properties Format=Custom and Custom=hh:mm tt but when i save this time in the Sql data base it is saved with complete date and time and when i retrieve it in a list view from database in start and end time Date is also mentioned that i dont want. Is there any way to display or save only the Time irregard of its Date.
Thnx in advace!
Majid Bhutta
Learning to work in C#.Net
|
|
|
|
|
From the SQL Online Books for MS SQL Server 2000:
Date and Time Data
Date and time data consists of valid date or time combinations. For example, valid date and time data includes both "4/01/98 12:15:00:00:00 PM" and "1:28:29:15:01 AM 8/17/98". Date and time data is stored using the datetime and smalldatetime data types in Microsoft® SQL Server™ 2000. Use datetime to store dates in the range from January 1, 1753 through December 31, 9999 (requires 8 bytes of storage per value). Use smalldatetime to store dates in the range from January 1, 1900 through June 6, 2079 (requires 4 bytes of storage per value).
So, in MS SQL Server 2000, you can't just store time as a data type. You have to figure out your own solution.
You could create INSERT and UPDATE triggers on the table that set the date portion of the time value to some goofy date like Jan 1, 1901 and, then, all times would relate to one another. But, that doesn't solve the problem of your list view.
I hope that it helps a little.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello...
u can save the time something like this :
here i am nt saving i m just displaying data in messagebox.
MessageBox.Show(Convert.ToDateTime(cmbxStartTimeList.Text).ToShortTimeString())
where cmbxStartTimeList.Text = 07:00 AM
and while retriving u can retrive by using ur old query den using the same
Convert.ToDateTime(UrRtriveString).ToShortTimeString()
and pass it to ur control.
hope it will help u.
Regards,
Praveen Solanki
|
|
|
|