|
Hello!
Assume this: I got two classes, namely CContainer and CItem . The container class declares a list of items like this:
private List<CItem> = new List<CItem>();
It fills this list somehow and offers a function like
public CItem GetItem(int nIndex);
This function returns the item at nIndex. The problem now is: how do I prevent the caller from modifying the returned CItem ?
In C++ we just put the const keyword into the declaration to achieve this. Any way to do it in C#? Is there a corresponding keyword?
Thanks in advance and best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
-- modified at 14:01 Saturday 18th March, 2006
|
|
|
|
|
Why would you like to prevent the calling code to moddify the return value?
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Have you considered having the GetItem() function simply return a clone of the Item so that if it gets changed, it doesn't matter?
Rich
|
|
|
|
|
There is no language support for C++ like const functionality. Having said that, you could declare CItem as a value type, this would result in a copy being returned to the client. Or you could clone the object yourself and return it to the client.
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
hi all !
datetimepicker get the christian date on my PC .however , How can I get the Arabic date from my System ( PC ) with the using of datetimepicker control.
thanks a lot .
Regards ,
s_mostafa_h
|
|
|
|
|
You'd need to change the culture of your program to an arabic one me thinks. I don't think there's away of using the standard datetimepicker to use a different calendar to the thread's culture.
However I havn't investigated
Ed
|
|
|
|
|
I noticed that when I run some Dotnet programs the icons in the background (XP desktop) flicker regularly.
I tried to find out what is happening and I managed to reproduce the problem with five lines of codes.
I hope someone will be kind enough to test that on their machine and tell me if they reproduce it or not.
You just need to
1 - create a new Windows Forms application.
2 - add a numericupdown control in the middle of the form
3 - set the numericupdown1 maximum to 1000
4 - Add the paint event for the form :
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
for (int i =1 ;i< numericUpDown1.Value;i++) {
e.Graphics.DrawLine(Pens.Red, 10 + i, 10, 10 + i, 10 + i);
}
}
5 - Add the value changed event on the NumericUpDown1
private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
{
this.Invalidate();
}
Then when you click on the NumericDown control and reach 150 (on my machine) the icons on the background are starting to refresh...
Do you reproduce that ?
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
Just checked it with .Net 2.0 and I have no flickering. I also can't remember that I noticed such a thing sometime in the past...
|
|
|
|
|
I think it must then be related to some other software I have installed.
thanks for you time
|
|
|
|
|
Hello!
I don't know if it is really possible, I have searched the internet for a solution, and haven't found anything... The problem is that I need to open a dialog of the Outlook of sending mail...
Any help will be appreciated!
Thanks in advance!
|
|
|
|
|
I found this tool on the internet, perhaps it would help
[^]
ADX Toys .NET is a free sample Outlook add-in /plugin that adds two useful features to Microsoft Outlook. This plugin allows you to examine real Internet headers and the body of the selected message. The add-in shows how to create custom command bars for Outlook Explorer and Outlook Inspector, get access to Outlook objects and add custom option and property pages. Also, this add-in illustrates how to use Extended MAPI to avoid Outlook security alerts.
|
|
|
|
|
Thank you very much!
Have a nice day!
|
|
|
|
|
hi!
how to launch and/or control windows connection (RAS)?
thanks!
|
|
|
|
|
Hi all,
Sorry for putting up the two silly questions (named Drawing on a Form & Drawing on an image).....
Jumped the gun and submitted it.
The problem was simple. The DrawString wasn't working because i had put that statement in the Load event handler method. The Load event is fired before the form is shown, and the Paint method was reworking and erasing all that i was drawing.
So, there was no need to get the graphics of the image. The form itself did the trick.
Thanks to all for bearing with me.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
..and these three threads that you created should have been kept in a single thread.
---
b { font-weight: normal; }
|
|
|
|
|
Sorry for any inconvinience caused....
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
My copy/paste operation results in a MemoryStream full of '\0' characters on the Clipboard.
Maybe my approach to copy/paste is wrong when handling generic types?
All entries in the CollectionBase are, of course, ISerializable and the binary serialization to file fully works. The collection is, to sketch the context, a set of shapes and connections of a diagram (application), see the Netron project[^] for details.
Thank you so much for you help.
The copy operation:
CollectionBase<IDiagramEntity> copy = MyDeepCopyOfTheCollectionViaSerialization();
DataFormats.Format format =
DataFormats.GetFormat(typeof(CollectionBase<IDiagramEntity> ).FullName);
IDataObject dataObject = new DataObject();
dataObject.SetData(format.Name, false, copy);
Clipboard.SetDataObject(dataObject, false);
where the MyDeepCopyOfTheCollectionViaSerialization() is :
CollectionBase<T> newobj = null;
MemoryStream stream = new MemoryStream();
GenericFormatter<BinaryFormatter> f = new
GenericFormatter<BinaryFormatter>();
f.Serialize(stream, this);
stream.Seek(0, SeekOrigin.Begin);
newobj = f.Deserialize<CollectionBase<T>>(stream);
stream.Close();
return newobj;
And finally the Paste operation is:
IDataObject data = Clipboard.GetDataObject();
string format = typeof(CollectionBase<IDiagramEntity> ).FullName;
if (data.GetDataPresent(format))
{
}
-- modified at 10:59 Saturday 18th March, 2006
|
|
|
|
|
NetronProject wrote: f.Serialize(stream, this);stream.Seek(0, SeekOrigin.Begin);newobj = f.Deserialize<collectionbase<t>>(stream);
What on earth you doing there?
Why not pass the just generated memorystream directly?
|
|
|
|
|
Ah! Interesting, though unorthodox idea. The logic is as follows; I first make a deep copy of the collection such that it's detached from the context. Since it's a copy of the collection is seemed logical to implement a 'Copy()' method. Of course, your suggestion is quite an interesting short-cut and I tried it out but...a Stream instance is not serializable and the pasting results in a 'null' value. On the other hand, an Image object is a kind of stream as well, no?
The Clipboard has never been my favorite.
Thanks a bunch for the idea! I have posted the question on Google, MSDN forums, here and you're the only one who has answered.
|
|
|
|
|
I have tried something similar, and as long as you remain with an application, rather use a static hashtable and map objects to GUID's or something. In my case I want to keep the proper uncloned references.
HTH
|
|
|
|
|
You know what...it's working. It seems things like
stream.Seek(0, SeekOrigin.Begin);
are not a good idea. Thanks!
By the way, your XACC project is really impressive.
Kind, F.
|
|
|
|
|
Hi!
I want to stream mp3 files from my home computer over the internet.
I want to be able to have a webpage on my computer where I can manipulate the playlist, choose next song, previous etc.
I would in other words need a live feed and I want to be able to stream different songs to different users.
Any ideas how this can be done?
/Dennis
|
|
|
|
|
dennisss80 wrote: I want to stream mp3 files from my home computer over the internet.
I dont think that you need to reinvent the wheel and try to stream the media yourself.
Use Windows Media Server as backend to host the media files and use either an asp page or any other custom application as front end.
dennisss80 wrote: I would in other words need a live feed and I want to be able to stream different songs to different users.
With Media Server, you can have your own songs playing in a playlist, which could be streamed over the internet. Also, you can have on-demand streaming.
dennisss80 wrote: I want to be able to have a webpage on my computer where I can manipulate the playlist, choose next song, previous etc.
So, all you got to do on the client side, is to use the Media Player ActiveX control to play the song.
Making a playlist is the logic that should be done by you. Something like, let the users choose the songs. Then you iterate through each song name and get it streamed as an on-demand streaming.
That all should do the trick.
Good Luck.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
dennisss80 wrote: I want to stream mp3 files from my home computer over the internet.
You might want to check with your ISP's Terms Of Service before you even try to set this up. Most ISP's, like Comcast, don't allow you to setup servers inside their network. But some do...
dennisss80 wrote: I want to be able to have a webpage on my computer where I can manipulate the playlist, choose next song, previous etc.
This will be a bunch of code on your part. You'll not only have to expose the Windows Media Server, but also a Web Server.
dennisss80 wrote: I would in other words need a live feed and I want to be able to stream different songs to different users.
How much upstream bandwidth do you have???? You may have 6Mb downstream, and only 128Kb to 512Kb up. Most people don't have the upstream bandwidth to support for more than about 3 people with any decent quality.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|