|
Thanks for your suggessions karkster. Unfortunately it's not working.
I came to know that the code is not working because my local machine does not have SMTP server installed on it. So I need to run the code on a machine where it is installed already. Will try for this.
|
|
|
|
|
You only need IIS, which comes with Windows
Do your best to be the best
|
|
|
|
|
Hello,
I'm doing some free-time programming with learning objective (in c#), and one of my "projects" led me to separate data taken from a text file.
Opening and retrieving data is no problem, I just put it into a ArrayList of string element for now. But when I want to separate the data from that ArrayList, the only solution I've come up with is as 'ugly' as this one:
ArrayList stream = new ArrayList();
(some code here)
foreach (string str in stream)
{
if (str.contains(some string))
{
do something
}
else
{
if (str.contains(some other string))
{
do other thing
}
else
{
(... even more if's)
}
}
}
I think there should be another way to do this, specially without so much "contains" operations that are time consuming.
Can you give me some directions on how to break such items apart?
I'm thinking this could also be used in other areas like socket communication.
This feels like a very dumb question to me, but if I don't ask, I'll never learn.
Thanks for any help you can give me.
|
|
|
|
|
Try using a List<string> template instead of an ArrayList. This class has a FindAll method that you could find to be helpful.
Hope it helps.
Do your best to be the best
|
|
|
|
|
It's a good sugestion, especially with the use of a "Predicate" in the search field.
However, now I've got a new question...
Is it possible with .net 2.0 to get a range of data between known delimiters using predicate's? This would be soooo much cleaner.
Thanks for the hint.
|
|
|
|
|
I don't want to be rude, but take a look in Visual Studio's Help - MSDN, you'll get most of your answers there.
rsaint27 wrote: Is it possible with .net 2.0 to get a range of data between known delimiters using predicate's?
I suppose you have seen that the FindAll method retuns a List<list>, so you can call the list's GetRange method...;)...would that help?
Do your best to be the best
|
|
|
|
|
Thanks again for your help,
And I'll look better in reference documentation before posting here.
|
|
|
|
|
Try it...it doesn't hurt
Do your best to be the best
|
|
|
|
|
i'm using maked textbox to get time as data in my application... i wana to subract values in masked textbox2 and masked textbox 1, but there comes an error that "-" opertor cannot be used for the operands in masked textbox, during compilation. pls help me solve the problem............
-- modified at 5:48 Monday 8th October, 2007
|
|
|
|
|
firstly use proper language.. not some 'i wana 2 subract'...
secondly.. give more description.. 'to get time format ' - 'wana 2 subract values in 2 textbox' so what o you really want?
some code maybe useful..
life is study!!!
|
|
|
|
|
Hi!
so i've got this generic method:
<br />
UserControl _control;<br />
<br />
public void InitializeSomething<Tclass>(WorkItem workItem) where Tclass : UserControl {<br />
_control = workItem.Items.AddNew<Tclass>();<br />
}
my goal is to call this method sth like this:
<br />
Type someType = typeof(someOtherObject);<br />
someObj.InitializeSomething<someType>(WorkItem);<br />
but this of course won't work..
my question is: is it possible to pass variable containing some type as Tclass for generic?!
thanks for any help!!!
life is study!!!
|
|
|
|
|
I don't really get what you're aiming for... Doe you want to create a collection of controls which are derived from some kind of type?
|
|
|
|
|
mmh..
well, for example List<>.. inside the <> you have to put class name.. and my aim is to pass this class name through some variable.
life is study!!!
|
|
|
|
|
You can't specify the type for generics with a variable. The point with generics is that the type is known at compile time so that the compiler can generate the code for the created generic type.
---
single minded; short sighted; long gone;
|
|
|
|
|
byte[] comparar = new byte[16];<br />
comparar[0] = 0x57;<br />
comparar[1] = 0x33;<br />
comparar[2] = 0x58;<br />
comparar[3] = 0x20;<br />
comparar[4] = 0x56;<br />
comparar[5] = 0x69;<br />
comparar[6] = 0x73;<br />
comparar[7] = 0x69;<br />
comparar[8] = 0x6f;<br />
comparar[9] = 0x6e;<br />
comparar[10] = 0x48;<br />
comparar[11] = 0x61;<br />
comparar[12] = 0x63;<br />
comparar[13] = 0x6b;<br />
comparar[14] = 0x20;<br />
comparar[15] = 0x31;<br />
<br />
byte[] regl = new byte[16];<br />
bool emp = false;<br />
string FName = @"c:\W3XVisionHack12003.exe";<br />
BinaryReader f = new BinaryReader(File.Open(FName,FileMode.Open),Encoding.ASCII);<br />
for (int i = 16; i <= f.BaseStream.Length; i++)<br />
{<br />
if (!emp)<br />
{<br />
for (int a = 0; a < 16; a++)<br />
regl[a] = f.ReadByte();<br />
emp = true;<br />
}<br />
else<br />
{<br />
for (int a = 0; a < 15; a++)<br />
regl[a] = regl[a + 1];<br />
<br />
regl[15] = f.ReadByte();<br />
}<br />
<br />
if (regl == comparar)<br />
MessageBox.Show("Found");<br />
<br />
}<br />
How i can comparate byte arrays? (my byte array with a BinaryReader byte array)
|
|
|
|
|
DiNeSat4 wrote: if (regl == comparar)
In this way you compare the instances of the 2 objects. If you want to compare 2 arrays you have to compare each element within those arrays
private bool AreEqual(byte[] a, byte[] b)
{
if (a.Length != b.Length)
return false;
for (int i = 0 ; i < a.Length ; i++)
if (a[i] != b[i])
return false;
return true;
}
Hope it helps.
Do your best to be the best
|
|
|
|
|
Damn men, thanks you
i'm happy
five stars to you
|
|
|
|
|
i am witing the following function
StoredProcedureInformation is a class i want to eturn it.
public StoredProcedureInformation ReturnStoredProcedureInformation(int length)
{
StoredProcedureInformation[] sp = new StoredProcedureInformation[length];
return sp;
}
Am i right?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
No. You are trying to return an array of StoredProcedureInformation objects but the return value of your method is defined as a single instance of a StoredProcedureInformation object. You should change your code to:
public StoredProcedureInformation[] ReturnStoredProcedureInformation(int length)
{
StoredProcedureInformation[] sp = new StoredProcedureInformation[length];
return sp;
}
Paul Marfleet
|
|
|
|
|
ThanQ
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Hi
If you want to return StoredProcedureInformation
class instance you need to construct an unstance of this class and return it
in your code you construct an array of StoredProcedureInformation and return the array instance.
|
|
|
|
|
Disable the automatic tooltip of treeview nodes in C#
plz...
venki
|
|
|
|
|
this.treeView.ShowNodeToolTips = false;
|
|
|
|
|
thanx..
but in 2003 i am not getting ShowNodeToolTips property....
help me.....
venki
|
|
|
|
|
I have the below campaign class. It is serialized to xml in my code. However, I do not want it to serialize the field if it's set to it's default value. In my case, 0 and 2001-01-01T00:00:00-08:00 for int's and datetime's respectively.
How can I have the XmlSerializer ignore them? Is there a global setting for the XmlSerializer class or attributes I can set for each field?
public class campaign : RESTResource
{
public override String get_endpoint_url()
{
return campaign.endpoint_url;
}
public static string endpoint_url = "/campaigns/";
public int id;
public string name;
public int category_id; if 0; don't serialize
public string subject;
public string body;
public string thumbnail;
public string notes;
public int ad_id_source; //If 0; don't serialize
public int campaign_status_id;
public DateTime valid_after;
public int billing_code;
public DateTime created_at;
public DateTime updated_at;
}
/\ |_ E X E GG
|
|
|
|