|
Okay so am I doing this wrong then.
Because my ForumList Class should be a collection of Forum objects ( could be other objects too, not just Forum )
List<T>
but I need to create new items of type "T"
and I also want to extend the List class to provide some custom operations.
How should the class declaration look?
Is that something like
public class ForumList : List<T> where T : class, new()
{
}
-- modified at 12:34 Wednesday 16th August, 2006
-- modified at 12:36 Wednesday 16th August, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
These should (at least be close to) be working:
If you want to inherit List<>:
public class ForumList<T> : List<T> where T : class, new() {
public ForumList() {}
public T AddNewItem() {
T item = new T();
this.Add(item);
return item;
}
}
If you want to keep the list private in the class:
public class FourmList<T> : IEnumerable<T> where T : class, new() {
private List<T> list;
public ForumList() {
this.list = new List<T>();
}
public T AddNewItem() {
T item = new T();
this.list.Add(item);
return item;
}
public IEnumerator<T> GetEnumerator() {
return (IEnumerator<T>)this.list.GetEnumerator();
}
}
---
b { font-weight: normal; }
|
|
|
|
|
Thanks Guffa.
So one last question.
does the "new()" take care of all constructors(overloaded parameters) or do I list out each possible one
like
new(int) I.e.. new(int id)
?
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
The "new()" constraint only specifies that the class have to have a parameterless constructor. You can't specify any constraint for overloaded constructors.
---
b { font-weight: normal; }
|
|
|
|
|
Nope, your T must have a parameterless constructor
|
|
|
|
|
public class ForumList<t> : IEnumerable where T : new()
{
public void CreateMe()
{
T myclass = new T();
}
|
|
|
|
|
I just wanted to ask whether there's a way to access a shared memory buffer, (between two apps), in c# with managed code
Background on what i wanna do!
I want to make an application which consists of a client and a server, the server listens for new data on the buffer, and the client sends data to the buffer,
Any help will be much obliged (Note: i don't want to use TCP/IP the server and client are on the same PC)
|
|
|
|
|
Look into the IPC[^] (inter-process communication) channel. This is designed for cross-process communication on the same machine.
|
|
|
|
|
You can use MS Messaging Queue
You can use it locally or over a network.
Another old-fashoined way is using a DDE Server(which is not recommended to be used over a network beacuase of security issues.)
|
|
|
|
|
hi friends,this is naidu.
I developed one small windows service project.In that i used notifyicon control for system displaying in system tray, when i install windows service in my system. But i did not get any notify icon when installed my windows service. Bur I got that with windows form applications.But is gives a problem with windows service.
Please help me my friends....
regards,
naidu.
|
|
|
|
|
Greetings,
Windows service is not meant for user interaction. If you still like to achieve this functionality i suggest creating a Forms Application, then adding windows service controller to control your windows service, and adding notify icon control to that app.
|
|
|
|
|
Use the following link as sample to create tray application .net.
http://www.windowsforms.net/articles/notifyiconapplications.aspx
ram
|
|
|
|
|
Hi,
my starting routine looks like this:
<br />
private void StartProcess()<br />
{<br />
System.Diagnostics.Process p = new System.Diagnostics.Process();<br />
p.StartInfo.FileName = "C:\\Programme\\AutoGK\\AutoGK.exe";<br />
p.Start();<br />
}<br />
When I run the code everything is executed fine except that the application to be started shows me an error: "Installation is corrupted. Please reinstall the application." But starting the app manually (in windows explorer, etc.) causes no errors and the application starts fine, so the problem is in the code I use. The program I want to start is AutoGordianKnot, which probably was written in Qt. Any suggestions or any other ways to start this app?
Greetings
|
|
|
|
|
Is the app usually started with command line parameters, perhaps?
|
|
|
|
|
Thought of that, too, but it is not!
|
|
|
|
|
I am working with the office outlook, it is working fine with console version, but when i use it with window service, it does not work.
I am getting the following log entry
Event Type: Error
Event Source: Microsoft Office 11
Event Category: None
Event ID: 2001
Date: 8/16/2006
Time: 6:38:46 PM
User: N/A
Computer: XYZ
Description:
The description for Event ID ( 2001 ) in Source ( Microsoft Office 11 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Microsoft Office Outlook, .
Any idea???
|
|
|
|
|
Windows service runs in a separate user context, i think this is the root cause of the problem.
Try running it under the same user as your console application (your login id).
Also try turning on "allow this service to interact with the desktop" feature.
|
|
|
|
|
Thanx for the reply but these solutions don't seem to work. The actual line of error is
Outlook.MAPIFolder objFolder;<br />
Outlook.NameSpace objNamespace;<br />
objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
here objFolder.Items.Count = 0. While in case of console application im getting the actual no of mails.
|
|
|
|
|
Hello,
I want the Schema of my dataset to be read in a while loop and printed out. Simple isn't it? Well it is not..Let me explain..I am calling the ReadXmlSchema as follows, (my dataset is called dsPersisted)
XmlTextReader reader = new XmlTextReader(new StreamReader(new MemoryStream(),Encoding.UTF8));<br />
<br />
dsPersisted.ReadXmlSchema(reader);
<br />
while (reader.Read())<br />
{<br />
Response.Write(reader.Name);<br />
}<br />
reader.Close();<br />
The Read() method inside the loop just doesn't work. Instead of a MemoryStream, if I use a filestream it works. But I don't want to use a filestream.
The dataset is definitely not empty and it has a schema (100% sure).
any help is appreciated
Siva
Sinceresiva
|
|
|
|
|
Hah!!! I myself have found the solution to the above problem. What I was getting was the following error
root element is missing
I modified the code as below and it works!!!
MemoryStream memStream = new MemoryStream();<br />
dsPersisted.WriteXmlSchema(memStream);<br />
<br />
memStream.Position = 0;<br />
<br />
XmlTextReader reader = new XmlTextReader(memStream);<br />
<br />
while (reader.Read())<br />
{<br />
Response.Write(reader.Name);<br />
}<br />
reader.Close();<br />
thanks,
Siva
|
|
|
|
|
Hi, i'm a newbie trying to connect to an Access 2000 database but keep getting the following error: "Could not find installable ISAM"
The code I am using is:
string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\myDB.mdb"<br />
<br />
OleDBConnection con = new OleDbConnection(conString);<br />
<br />
con.Open();
Some help would be greatly appreciated.
Thanks
|
|
|
|
|
Change "DataSource" to "Data Source".
---
b { font-weight: normal; }
|
|
|
|
|
I noticed you posted this also in the SQL message board. Note that cross-posting will get you flamed by some!
|
|
|
|
|
sorry, I didnt realise! thanks for the help, Guffa!. school boy error!! the code now works. it was just a syntax error - "Data Source" rather than "DataSource"
-- modified at 11:46 Thursday 17th August, 2006
|
|
|
|
|
Hi guys,
does anyone have some sample code or a link to some sample code for a HTTP POST which sends a string to a url and recieves a string as a response?????????
Will
|
|
|
|