|
Thanks alot for your reply ... i am not getting the syntax ..
like how to read the gridvalue
// some code to convert dataset [] val=datagrid1.rowsSlected
after getting above i can do like
textBox1.text=dataset[0];
....
.
.
.
.
i tried with hardcoded values like textbox1.text="5"
then onload the page is having the value in text field 1 ...
please help me here..
vikas da
|
|
|
|
|
dataset.Rows[0][0] if 0 is the selected row.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I am trying to add an item to a list box from another class. I can add an item from within the same class with no problem, but when I try to add it from another class nothing happens even though when I folow it through it goes through all of the code. Can someone tell me how to resolve this problem (see below).
Thanks in advance,
Michael
Class1
{
buttonAddItem()
{
AddItem(); // Adding and item to my listbox works here.
}
public void AddItem()
{
this.ListBox.BeginUpdate();
this.ListBox.Items.Add(“AAA”);
this.logListBox.EndUpdate();
}
}
Class2
{
Class1 C1 = new Class1();
C1.AddItem(); // Adding from C2 to C1 does not work.
}
|
|
|
|
|
Looks to me like you need to do some reading on how OO works. Creating a new Class1, means exactly that. C1 has NOTHING to do with any other Class1 instance that is already running in your code. C1 will indeed add that item. But, it's not visible anywhere, so why would you see it ? A DIFFERENT Class1 instance continues to show the items that it has.
The correct way to deal with this is to set up delegates between the two classes. This needs to be done outside the constructor, obviously.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Seems like a few posts floating around here needing a refresher on OOP today...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I quess I don't understand because I am only telling class1 to run the method which adds the Item item to the ListBox, I am not trying to add it from another class.
|
|
|
|
|
hehe BeginUpdate() on ListBox and EndUpdate() on logListBox anyway
you can make that method static and can pass ListBox as a parameter then add items, something like this :
public static void AddItems(ListBox tmp_LB)
{
tmp_LB.BeginUpdate();
tmp_LB.Items.Add("AAA");
tmp_LB.EndUpdate();
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
class MyClass3
{
public static int i;
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(MyClass3.i);
Console.ReadKey();
}
}
I get a zero on the console.
How is the static field getting initialized.
|
|
|
|
|
simple
MyClass3.i = XX
XX any numeric value
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You can have a static constructor to initialize it or you can just assign it any value you wish from the code that uses this static class.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
If your question was, why the value is 0 although it has nowhere been initialized, then the C# language specification[^] tells you why:
5.2 Default values
The following categories of variables are automatically initialized to their default values:
* Static variables.
* Instance variables of class instances.
* Array elements.
The default value of a variable depends on the type of the variable and is determined as follows:
* For a variable of a value-type, the default value is the same as the value computed by the value-type’s default constructor (§4.1.2).
* For a variable of a reference-type, the default value is null.
Initialization to default values is typically done by having the memory manager or garbage collector initialize memory to all-bits-zero before it is allocated for use. For this reason, it is convenient to use all-bits-zero to represent the null reference.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Instance variables are initialized when we make an object of the class with the "new" keyword. Similarly with arrays. But in this case we dont use the new keyword. So how does it get initialized to its default value.
|
|
|
|
|
int is a value type, so it's default (empty) constructor will be called automatically by the runtime by the time you try to access it.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello,
I have an application that has a thread waiting on a Console.Readline to finish. Aborting the thread using Thread.Abort won't work. But if I could generate a Console.Readline the thread would end in a controlled fashion. But, how do I generate something that triggers a Console.Readline from within my application? Please help.
|
|
|
|
|
Close the port perhaps, not sure what you have hooked up to the Console stream.
|
|
|
|
|
i want to retrieve associated program path from registry and i did, output comes as it should but i have to use tricks to get it in use, the path comes as
"C:\abc\efg.exe" "%1"
ok i can just use Split() with " as param but some paths come as
C:\abc\efg.exe %1
now i can use use Split() with % as param
are these ways correct ? or anyother good way ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: are these ways correct ?
If they work correctly they are correct, mostly.
Xmen wrote: or anyother good way ?
Maybe Regular Expressions, maybe?
led mike
|
|
|
|
|
oh but what if path have '%' then split function wont work properly
edited :
i got better way :
tmp_string = tmp_string.Replace("\" \"%1\"", "").Replace(" \"%1\"", "").Replace(" %1", "");
if (tmp_string.StartsWith("\""))
tmp_string = tmp_string.Remove(0, 1);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Split on SPACE, honoring QUOTEs... oh, yeah, Split ignores QUOTEs ... that's why I wrote my own!
I still hope to find a Regular Expression that will do it.
|
|
|
|
|
my way is better, spilitting Space may give incorrect output because path can have space too
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Which is why you have to honor the QUOTEs.
|
|
|
|
|
what is honor ????
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Recognizing that everything between the QUOTEs is one value and is not to be split.
|
|
|
|
|
class MyClass
{
public MyClass(int b)
{
Console.WriteLine(b);
}
public MyClass()
: this(43)
{
Console.WriteLine("Default Const");
}
}
class MyClass2 : myClass
{
public MyClass2(int b) : base(b)
{
Console.WriteLine(b);
}
public MyClass2()
{
Console.WriteLine("Default Const");
}
}
In the above code in my MyClass2 non- default constructor. It is giving a value back to the base class. I want to know if at the same time can I make the default constructor run.
I mean something like this
public MyClass2(int b) : base(b),this()
or this
public MyClass2(int b) : base(b) : this()
How do I do it
|
|
|
|
|
humayunlalzad wrote: How do I do it
Best practice would be to refactor the code out into a member function so that it can be called.
led mike
|
|
|
|