|
What do you mean by the "C# imagebox"?
---
b { font-weight: normal; }
|
|
|
|
|
|
How can i Find String in DataTable or DataSet.
|
|
|
|
|
hi there,
u can play with 'Find' method of DataTable object.
it'll returen DataRowcollection that contains collection of rows that match with ur search criteria
<< >>
|
|
|
|
|
But with 'Find' method of DataTable object we can not find Partlly String it find full matching of string.
|
|
|
|
|
Hi all,
I just want to share this with you. There's people who loves writing software in notepad, i'm one of them. Programming with notepad can get you a big headache but in my opinion is more flexible in terms of custom components (custom editor, custom compiler, custom resource creator) and is very handy at compile time, using batch files (.bat) is the most common option for compilation when notepad is used instead an IDE.
C# programmers are going to love this notepad replacement. So i posted this message in the .Net Framework and here.
I just found an incredible Opensource text editor for us: Notepad++
http://notepad-plus.sourceforge.net/uk/about.php[^]
You can download an executable with installer and a zipped version for people who likes "clean" apps.
It's not a resource hungry app, it's a notepad with syntax highlighting (many languages) and format encoding, and no additional features such as code completion, and others. It's a real tool for real brainy programmers.
Enjoy
|
|
|
|
|
trying to understand
StateObject param in BeginRecieve.
any info about it would be greatly appreciated.
It popups in MS documentation as if
it is something obvious and needs no
explanation.
it appears that StateObject is mapped to
OVERLAPPED structure in win32 api, it is possible
to relate offsethigh and offsetlow to stateobject's fields but
what happens to StateObject once it gets inside
BeginRecieve and what changes happen to it ?
also why in MS sample StateObject has Socket type
field.
TIA
|
|
|
|
|
It's just a convenient place holder for something that you want to pass to the callback function. Whatever is passed in the state object can be retrieved inside the callback using the IAsyncResult.AsyncState property. For example
void Start()
{
string test = "Senthil rocks";
s2.BeginReceive(so2.buffer, 0, StateObject.BUFFER_SIZE,0,
new AsyncCallback(Async_Send_Receive.Read_Callback), test);
}
void Async_Send_Receive.Read_Callback(IAsyncResult result)
{
string s = (string)result.AsyncState;
}
You'll usually pass something more useful, such as the socket object on which you will call EndReceive.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
thank you,
could you also clear this for me:
I am doing a single submit class to send tons of GET/POST
requests where I wrap all socket related functions.
So if I have a class level Socket object(public or private) why
do I still need to pass socket parameter around when the same
object can be accessed in any function.
Is it because sticking to local variables is considered to be
a better programming practice or I must pass local object when
it comes to callbacks functions ?
TIA
|
|
|
|
|
If your socket object is a class level member variable, then yes, there's no need to pass it as in the state parameter.
Having it as a local variable gives a very minor advantage, the GC will be able to collect the socket object quicker, as there will be no outstanding references once the callback completes. Having it as a member variable means that the reference will be valid till the parent class is alive.
Not worth making it as a local variable just for that though.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I'm looking for assistance with writing the following calculation in C#
n!
n_P_k = --------
(n - k)!
and/or
n!
n_C_k = ----------
k!(n - k)!
any ideas would be helpful!
-- modified at 21:03 Friday 9th September, 2005
|
|
|
|
|
You only need a function to calculate the factorial of a number. You can then pass it n and n-k and then divide to get n_P_K. A simple implementation of factorial will look like this
long factorial(int n)
{
int x = 1;
for (int i = 2; i<=n; ++i) x*= i;
return x;
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
using System;
namespace fact
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
//calculate n!
Console.WriteLine("Enter the value of N");
int nFact = 1;
int nComputeTo =int.Parse(Console.ReadLine());
int nCurDig = 1;
for (nCurDig=1;nCurDig <= nComputeTo; nCurDig++)
nFact *= nCurDig;
int Nfactorial=nFact;
Console.WriteLine("n! = "+nFact+"\n");
//calculate (n-k) !
Console.WriteLine("Enter the value of K");
int nFact1 = 1;
int k=int.Parse(Console.ReadLine());
int nComputeTo1=nComputeTo-k;//n-k
int nCurDig1 = 1;
for (nCurDig1=1;nCurDig1 <= nComputeTo1; nCurDig1++)
nFact1 *= nCurDig1;
int NminusKfactorial=nFact1;
try
{
int npk=Nfactorial/NminusKfactorial;//n_p_k=n!/(n-k)!
Console.WriteLine("(n-k)! = "+nFact1+"\n");
Console.WriteLine(" n_p_k="+npk);
Console.ReadLine();
}
catch(DivideByZeroException ex)
{
Console.WriteLine(ex.Message);
}
catch(OverflowException ex)
{
Console.WriteLine(ex.Message);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
|
|
|
|
|
You can simplify your code for P(n, k):
int P(n, k)
{
int value = 1;
for(i = n; i>k; --i)
value *= i;
return value;
}
int C(n, k)
{
return P(n, k)/P(k,1);
}
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Thanks for all the suggestions. Now another question.
What data type should be used for numbers > long?
The above examples work great for 10_P_4 but I'm getting divide by zero's for 100_P_10.
I belive it's because 100! > long.
using this routine -----
long x = 1;
for(long i = 2; i <=n; ++i)
x *= i;
Debug info ----
n=100
i=2;x=2
i=3;x=6
i=4;x=24
i=5;x=120
i=6;x=720
i=7;x=5040
i=8;x=40320
i=9;x=362880
i=10;x=3628800
i=11;x=39916800
i=12;x=479001600
i=13;x=6227020800
i=14;x=87178291200
i=15;x=1307674368000
i=16;x=20922789888000
i=17;x=355687428096000
i=18;x=6402373705728000
i=19;x=121645100408832000
i=20;x=2432902008176640000
i=21;x=-4249290049419214848
i=22;x=-1250660718674968576
i=23;x=8128291617894825984
i=24;x=-7835185981329244160
i=25;x=7034535277573963776
i=26;x=-1569523520172457984
i=27;x=-5483646897237262336
i=28;x=-5968160532966932480
i=29;x=-7055958792655077376
i=30;x=-8764578968847253504
i=31;x=4999213071378415616
i=32;x=-6045878379276664832
i=33;x=3400198294675128320
i=34;x=4926277576697053184
i=35;x=6399018521010896896
i=36;x=9003737871877668864
i=37;x=1096907932701818880
i=38;x=4789013295250014208
i=39;x=2304077777655037952
i=40;x=-70609262346240000
i=41;x=-2894979756195840000
i=42;x=7538058755741581312
i=43;x=-7904866829883932672
i=44;x=2673996885588443136
i=45;x=-8797348664486920192
i=46;x=1150331055211806720
i=47;x=-1274672626173739008
i=48;x=-5844053835210817536
i=49;x=8789267254022766592
i=50;x=-3258495067890909184
i=51;x=-162551799050403840
i=52;x=-8452693550620999680
i=53;x=-5270900413883744256
i=54;x=-7927461244078915584
i=55;x=6711489344688881664
i=56;x=6908521828386340864
i=57;x=6404118670120845312
i=58;x=2504001392817995776
i=59;x=162129586585337856
i=60;x=-8718968878589280256
i=61;x=3098476543630901248
i=62;x=7638104968020361216
i=63;x=1585267068834414592
i=64;x=-9223372036854775808
i=65;x=-9223372036854775808
i=66;x=0
i=67;x=0
i=68;x=0
i=69;x=0
i=70;x=0
i=71;x=0
i=72;x=0
i=73;x=0
i=74;x=0
i=75;x=0
i=76;x=0
i=77;x=0
i=78;x=0
i=79;x=0
i=80;x=0
i=81;x=0
i=82;x=0
i=83;x=0
i=84;x=0
i=85;x=0
i=86;x=0
i=87;x=0
i=88;x=0
i=89;x=0
i=90;x=0
i=91;x=0
i=92;x=0
i=93;x=0
i=94;x=0
i=95;x=0
i=96;x=0
i=97;x=0
i=98;x=0
i=99;x=0
i=100;x=0
-- modified at 14:41 Saturday 10th September, 2005
|
|
|
|
|
|
<br />
private void open_Database(string XML_DB_Name)<br />
{<br />
dataSet.ReadXml(XML_DB_Name);<br />
DataTable dt = dataSet.Tables[0];<br />
string tblName = dt.TableName;<br />
currentTable = dataSet.Tables[tblName];<br />
dataGrid1.SetDataBinding(dataSet, tblName);<br />
dataGrid1.CaptionText = tblName;<br />
<br />
DataRow MyRow = currentTable.Rows[0]; <---- Problem when currentTable is empty, i get an exception...probably i can get the RowCount in another way?<br />
int RowCount = MyRow.Table.Rows.Count;<br />
<br />
foreach(DataTable dTable in dataSet.Tables)<br />
{<br />
DataGridTableStyle dgStyle = new DataGridTableStyle();<br />
dgStyle.MappingName = dTable.TableName;<br />
if(RowCount < 8)<br />
{<br />
dgStyle.PreferredColumnWidth = 120;<br />
}<br />
else<br />
{<br />
dgStyle.PreferredColumnWidth = 110;<br />
}<br />
dataGrid1.TableStyles.Add(dgStyle);<br />
}<br />
}<br />
i get this exception:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
Additional information: There is no row at position 0.
But i want to have the rowcount also when its 0!!
cu
|
|
|
|
|
surfman19 wrote:
DataTable dt = dataSet.Tables[0];
surfman19 wrote:
DataRow MyRow = currentTable.Rows[0]; <---- Problem when currentTable is empty, i get an
An array has to have at least 1 variable placeholder. Make the [0] to [1].
|
|
|
|
|
In most C style languages like C#, array indexes usually start with 0 rather then 1. For loops usually follow this form.
for(int i=0; i<list.count; ++i)
="" do="" something="" with="" list[i]="" here=""
<hr=""> I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
if (currentTable.Rows.Count > 0)
{
}
Should help
Gary
Marc Clifton: "In other words, VB is like a bad parent. It can really screw up your childhood."
|
|
|
|
|
solved:
<br />
int RowCount = dt.Rows.Count;<br />
cu
|
|
|
|
|
I have a file that has a serialized object in it.
I wrote ANOTHER program that I wanted to read that object.
When I attempt to Deserialize I get the following execption:
Unable to find assemble 'Address, Version 1.0.0.0, Culture=neutral, PublicKeyToken=null
To make sure the second program new about the class object that was stored in the file, I copied the class to the new program. I also copied the Serialize and Deserialize code that works on the first program to the second program. The first program can read and write with no problems to this file. Both programs were created in MS's Visual C# 2005 Express Edition Beta.
Anybody have an idea why one program can not read a serialized file created by another program?
Thanks for any help,
Dave
|
|
|
|
|
You can't copy a class by coping the source code for it. That will only create a class that looks exactly the same, but it is not the same class.
Compile the class by itself, so that you can reference the dll from both programs.
---
b { font-weight: normal; }
|
|
|
|
|
That still wont work. According to MSDN, a serialized stream will NOT deserialize in any program except the one that serialized it. Maybe of your new program has the same assembly name and such it may work.
I searched for days for this answer until I came scross that on MSDN.
|
|
|
|
|
Does anyone know how to make DebugView from SysInternals "work"? I am trying to write a C# program in .NET 2003 and to print 2 lines:
System.Diagnostics.Debug.WriteLine("I am debugging");
System.Diagnostics.Trace.WriteLine("I am Tracing"); I start dbgview.exe, run my program, and I do not see those comments (I checked that I am in debug mode). I have seen references to some kind of TraceListener, but I don't know what that is or where to set it up.
If anyone knows what I'm talking about, could you please link me to some pertinent info? My quick search on google didn't give me anything.
Thanks
Sue
|
|
|
|