|
Thanks ejuanpp. Not a bad idea, but I'll be in the same problem: end-developers need to handle it externally or do some kind of validation afterwards and the API will not be consistent.
I'd like to avoid to leave the default object creation way or do anything "non-standard" to make easier other developers life.
|
|
|
|
|
I don't know what ur actual intention is,
If your intention is to prevent object creation using default constructor aking ur Default Constructor private will solve ur issue.
|
|
|
|
|
hi
i want to start network Programming with VCc#2005 (from begin to advance)
i want to create Client/Server Application that detect Clients on the Network and Send/Recive Data across the Network.
Can Somebody Help me ??
Note : I am beginner in Network Programming and i want to use Standard FrameWork Classes and don't want to use User Classes.
Thanks.
|
|
|
|
|
There are plenty of examples on the internet. You need to learn about socket programming. Use "System.Net.Sockets" or check out this project: http://www.codeplex.com/IndySockets
It is still under work but the developers are professionals in socket programming, so download the snapshots and you can learn a lot.
This is the original Indy Sockets written in Delphi, but runs on .NET as well: http://www.indyproject.org/Sockets/index.en.aspx
|
|
|
|
|
thanks for reply
but it has not example for c# and it is a dll, I want to learn NetWork in c# 2005 and i need a basic articles,ebooks or ...
|
|
|
|
|
|
Hello,
I am new to C#, I was progressing at Giant Steps until I hit this plateau.
Say I have a passed index, or a for loop index of which the index number determines the choice of the image to show:
It is something like this. Ex:
MyMethod(int index, int category)
{
int indic = category ;
string sText,textype ;
StringBuilder sss = new StringBuilder();
PictureBox pbx = new PictureBox() ;
string strMm = "LSB_Box" + category ;
sss.Append(StrMm);
// My best guess was
pbx.Name = sss.ToString ;// I tried pbx = sss !! compile complaints!!
pbx.Image = EventTesterMe.Properties.Resources.LSB_Boolean_IMG_+index;
}
I other words i wish to be able to populate LSB_Box1 or 2 to 5 with any image in my resource box named EventTesterMe.Properties.Resources.LSB_Boolean_IMG_1 ... to 15; According to calculation performed. (And I dont want to reproduce and type the same funtion 64 times for each occurance!).
With no luck. I tried string builder, Regex, string, you name it, Compiler complain that I cannot implicitly convert string to sys.sys.form ect.. pictureBox type!! 48hours Stuck !!
In WinDev9 I can do myAlias is a string; then MyAlias = (MyBase+MyCount); and use {MyAlias}..Method(); And works OK, but here in C# is there any similar action for distribution.
Please guide me where to look, or tell me the right method.
Thanks in advance for any help.
MikkaH.
If you dont know were you are,look back were you come from. (Some time one dont know how far they travelled) Next time before you complain ! Give a friendly look to your sole. (African Wisdom). for{
|
|
|
|
|
If you want to operate on one of many similar items (in your case LSB_Box1...5) you
must put them in a collection, e.g. an array. Hence (assuming LSB_Box1...5 are of
type LSBtype):
LSBtype[] LSBarray=new LSBtype[5]{LSB_Box1, LSB_Box2, LSB_Box3, LSB_Box4, LSB_Box5};
LSBarray[indx].SomeProperty=someValue;
BTW: you can omit the array size (here 5) when the compiler can derive it from the
initializer list!
Luc Pattyn
|
|
|
|
|
Thanks Luc,
It worked right away, had some hint though, but could not reference properly.
Ready for another leap in C#.
Merci !!
If you dont know were you are,look back were you come from. (Some time one dont know how far they travelled) Next time before you complain ! Give a friendly look to your sole. (African Wisdom).
|
|
|
|
|
PLEASE HELP!!!! I have been spending a huge amount of time figuring this out and no luck. I have the below code and it keeps failing on me saying the index is out of range. I am using it to parse the following file information. The file itself doesn't have SSSSSSSSSSSSSSSSSSSSSSS and if add it in it works fine but without it I get the index out of range error and that the index must be non-negative.... Please help. I can using regex to match -REMIT TO- and then using the code below. Ohh and I am wanting to get FWKKK as scolVenCode and X001022227:15 as scolOurInv.
0 GEOGRAPHIC DATA COMPANY NAME HERE
SSSSSSSSSSSSSSSSSSSS INVOICE NUMBER - 00ABBB33333
INVOICE DATE
12/14/06
- FWKKK X001022227:15 -REMIT TO-
Match m2=rOurInv.Match(fileWhole);
if (m2.Success)
{
int intTemp=m2.ToString().IndexOf("-REMIT");
sOurInv = m2.ToString().Substring(0, intTemp).Trim();
if (sOurInv.StartsWith("-")== true)
{
sOurInv=sOurInv.Substring(1).Trim();
}
arrTemp= sOurInv.Split();
scolOurInv.Add(arrTemp[arrTemp.GetUpperBound(1)]);
scolVenCode.Add(arrTemp[arrTemp.GetLowerBound(0)]);
}
sasa 1
|
|
|
|
|
When accessing arrays (or characters in a string) the index must be in the range
[0, length-1] inclusive. Seems like your code is violating this somehow.
may I suggest:
1) you put the whole thing inside a try-catch construct and print out all the
exception information in the catch part, to get an accurate readout of what
goes wrong where (when using Visual Studio, you will get a line number)
and/or
2) you improve the observability of what is going on by inserting
COnsole.WriteLine() or other debug statements, so you can check wether your
assumptions are correct, e.g. the value of intTemp.
Luc Pattyn
|
|
|
|
|
how can i write the program alike search in windows? Help plz!
|
|
|
|
|
hi,
you can use DirectoryInfo and FileInfo Classes from System.IO namespace and do recursive search.
|
|
|
|
|
Hi all
i have the folloeing code to run a batch file
System.Diagnostics.ProcessStartInfo psiinfo=new System.Diagnostics.ProcessStartInfo("aaa.bat");
psiinfo.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden;
psiinfo.CreateNoWindow=true;
System.Diagnostics.Process p1=System.Diagnostics.Process.Start(psiinfo);
while(!p1.HasExited);
//
//Following some other code
//
It works fine with Xp and 2000. But the problem comes with windows 98
in that after executing the batch file the batch file will not get closed . instead it will become an inactive window and the user has to close it manualy . So "has Exited " is not working here since the process is not getting closed. is there any way to find out whether the process in inactive or completed execution ..
thanks in Advance
AnnS
Suffering cheerfully endured, ceases to be suffering and is transmuted into an ineffable joy.
|
|
|
|
|
Try giving other processes some CPU time as well: replace your while loop by:
while(!p1.HasExited) Thread.Sleep(200);
AFAIK older Windows such as Win98 are not as good in switching processes in time,
so you should not choose a delay that is much smaller; your code was keeping the
current process very busy, and I guess Win98 could not deal with that.
Luc Pattyn
|
|
|
|
|
hi all
i want to darw a waterfall diagram with directx . but i don't know how and from where should i begin .
any idea would be helpfull.
|
|
|
|
|
You will need the DirectX SDK package, and some examples.
Search for DirectX on CodeProject !
Luc Pattyn
|
|
|
|
|
Hello,
I am developing a windows service in VS 2005 that will monitor time and do something every 5 seconds.
I have created some code using the stopwatch class. Can anyone tell me if this is the best way to do this .
<br />
protected override void OnStart(string[] args)<br />
{<br />
sw.Start();<br />
this.RunningTime();<br />
}<br />
<br />
protected override void OnStop()<br />
{<br />
sw.Stop();<br />
}<br />
<br />
private void RunningTime()<br />
{<br />
if (sw.IsRunning)<br />
{<br />
if (sw.Elapsed.Seconds == 5)<br />
{<br />
}<br />
}<br />
}<br />
Many thanks in advance,
Steve
|
|
|
|
|
In my opinion the best way would be to use one of the timer classes cause by using StopWatch you would end up with active waiting. As you're programming a service the System.Windows.forms.Timer component should not work as it relies on a message pump, but you can either use System.Timers.Timer or System.Threading.Timer class. Take a look at their documentation to get an idea on how to use them.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I am framing a sql statement like this select file_id,file_name from XCalibur_files where path Like 'c:\xalibur\*'(
C:\xcalibur\system\programs path exists in the table)
but it is returning zero results.
This is the code..
string AccessConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Xcalibur\System\Programs\XCalibur Database.mdb;Jet OLEDB:Database Password=170464PassFinn;";
//Create an OleDbConnection object,
//and then pass in the ConnectionString to the constructor.
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = AccessConn;
//Open the connection.
cn.Open();
string str1 = "select file_id,file_name from XCalibur_files where path Like '";
string str2= "c:\\xalibur\\"+ "*'";
//Use a variable to hold the SQL statement.
string selectString =str1+str2 ;
//Notice that this line passes in the SQL statement and the OleDbConnection object
OleDbCommand cmd = new OleDbCommand(selectString,cn);
//Send the CommandText to the connection, and then build an OleDbDataReader.
//Note: The OleDbDataReader is forward-only.
OleDbDataAdapter oledataadapter= new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
oledataadapter.Fill(ds);
MessageBox.Show(ds.Tables[0].Rows.Count.ToString());
Where i am doing wrong?
|
|
|
|
|
If I recall right the "*" character has no special meaning in a LIKE clause for Access or at least not the one it has in a shell. I think you have to use the "%" character if you want to match all path starting with "c:\\xalibur\\".
Furthermore you should use parameterized queries instead of building the queries by string concatenation as the latter is more error-prone and not safe against injection attacks. Take a look at the following article for more information: SQL Injection Attacks and Some Tips on How to Prevent Them[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
when i try to save a image to hard disk i got a Error ,Generic Error Ocurred GDI+
this is the code
img.save(path,imageformat);
please help
""""""""
|
|
|
|
|
This error is quite general, and ill descriptive. Could you please post more code of what you are trying to do exactly?
Regards
|
|
|
|
|
|
PS.
Your question -and code which is not surrounded bu pre tags- is a bit vague. I'm taking guesses here.
You don't need to call the event handler itself -though there are ways of doing it-. You can simply extract the code into a common method:
private void b1_Click()
{
MyMthod();
}
private void MyMethod()
{
}
Was that what you were looking for?
Regards
|
|
|
|