Click here to Skip to main content
16,007,809 members
Home / Discussions / C#
   

C#

 
GeneralRe: Memory leaks Pin
Heath Stewart28-Jul-04 6:37
protectorHeath Stewart28-Jul-04 6:37 
GeneralIL code generation on the fly Pin
SOCM_FP_CPP28-Jul-04 2:15
SOCM_FP_CPP28-Jul-04 2:15 
GeneralRe: IL code generation on the fly Pin
Nick Parker28-Jul-04 3:12
protectorNick Parker28-Jul-04 3:12 
GeneralToolbox Visibility Question - Custom Controls Pin
ddelapasse28-Jul-04 1:39
ddelapasse28-Jul-04 1:39 
GeneralRe: Toolbox Visibility Question - Custom Controls Pin
leppie28-Jul-04 3:13
leppie28-Jul-04 3:13 
GeneralRe: Toolbox Visibility Question - Custom Controls Pin
Heath Stewart28-Jul-04 4:54
protectorHeath Stewart28-Jul-04 4:54 
GeneralRe: Toolbox Visibility Question - Custom Controls Pin
Nick Parker28-Jul-04 4:53
protectorNick Parker28-Jul-04 4:53 
Questionhowto generalise compareoperations? Pin
Stephan Wright28-Jul-04 1:34
Stephan Wright28-Jul-04 1:34 
Hy everyone!

I do want to generalize some comparestatements or assignstatments in my C# proggy. I managed to do so when I had a sender object (casting it) but now there is none and I am stuck.

My datastructure looks like this:
ldata contains the data
this looks like this
ldata[]
||=> keys[]
|| ||=> keyID //id of the field to display the data in
|| ||=> telnumber //the data to being displayed
||=> telefonID //the telefonnumber for which to display data

the telefonID should not matter, you can switch the numbers but only one of those is displayed at once, meaning you select one and the data for this number is displayed. But this doesn't matter concering my problem because at this stage the number has already been selected and I do just have to display the data for the selected number or check for changes before either switching numbers or just to save them.

My code looks like this at the moment:

//displaying the data<br />
for(li=0;li<ldata[0].keys.Length;li++)<br />
{<br />
  if(ldata[0].keys[li].keyId==1)<br />
  {<br />
    txtNameKey01.Text=ldata[0].keys[li].telephoneNo;<br />
  }<br />
  // repeated for all 12 TextBoxes <br />
}<br />
<br />
// comparing for changes (new data typed in Textbox?)<br />
for(li=0;li<lTelephone[0].keys.Length;li++)<br />
{<br />
  if (lTelephone[0].keys[li].keyId==1)<br />
  {<br />
    if (lTelephone[0].keys[li].telephoneNo!=txtNameKey01.Text)<br />
	// assign the changed number to an array containing all changed fields<br />
  }<br />
  // once again repeated for every 12 TextBoxes<br />
}


But well this isn't nice Frown | :( and even harder to change lets say to 24 TextBoxes, but well it works Wink | ;) . What I do want to do now is change the thing above to something like

// for displaying<br />
for(li=0;li<ldata[0].keys.Length;li++)<br />
{<br />
   //TextBox should be the "general" object<br />
   //ID of this "general" object should be the keyID<br />
   TextBox=ldata[0].keys[li].telnumber;<br />
}


The pseudocode above and beneeth should describe what I want to do. I do want to create a general object/variable/... whatever to just having to assign or compare in one statement. I do want the keyID to describe where the data should be sent to or which fielddata should be compared to.
With strings you are able to copy parts together like "hello"+"world"+year.ToString() => hello world 2004 but this doesn't work with assignments, does it? Unsure | :~

// for comparing for changed numbers<br />
for(li=0;li<lTelephone[0].keys.Length;li++)<br />
{<br />
  //TextBox once again a "general" object<br />
  if (lTelephone[0].keys[li].telephoneNo!=TextBox.Text)<br />
     //assign the changed number somewhere for further use		<br />
}


in the pseudocode above once again it should be using the keyID to decide which TextBox I am really doing the comparison with.

But at the moment I do wonder if this is really possible or if I have to live with this if-statements and with tons of code for comparison and assignments! OMG | :OMG:

Thanks!
Stephan.
AnswerRe: howto generalise compareoperations? Pin
Daniel Turini28-Jul-04 1:53
Daniel Turini28-Jul-04 1:53 
GeneralRe: howto generalise compareoperations? Pin
Stephan Wright28-Jul-04 2:16
Stephan Wright28-Jul-04 2:16 
QuestionDo MS Collection Class Enumerators use strong reference to keep collection alive? Pin
Paul Evans28-Jul-04 1:29
Paul Evans28-Jul-04 1:29 
AnswerRe: Do MS Collection Class Enumerators use strong reference to keep collection alive? Pin
Daniel Turini28-Jul-04 1:55
Daniel Turini28-Jul-04 1:55 
GeneralLicense Key Create / Validate for windows Application Pin
wcoods28-Jul-04 0:42
wcoods28-Jul-04 0:42 
GeneralRe: License Key Create / Validate for windows Application Pin
Heath Stewart28-Jul-04 4:39
protectorHeath Stewart28-Jul-04 4:39 
GeneralFinding File names from an Executable Pin
Lee Majors27-Jul-04 23:19
sussLee Majors27-Jul-04 23:19 
GeneralRe: Finding File names from an Executable Pin
Colin Angus Mackay28-Jul-04 0:17
Colin Angus Mackay28-Jul-04 0:17 
GeneralRe: Finding File names from an Executable Pin
Lee C Baker28-Jul-04 0:56
Lee C Baker28-Jul-04 0:56 
GeneralRe: Finding File names from an Executable Pin
Heath Stewart28-Jul-04 4:19
protectorHeath Stewart28-Jul-04 4:19 
GeneralSerializing COM objects Pin
wute527-Jul-04 14:06
wute527-Jul-04 14:06 
GeneralRe: Serializing COM objects Pin
Heath Stewart28-Jul-04 4:27
protectorHeath Stewart28-Jul-04 4:27 
GeneralAutomatically Display Expire Date Pin
ASGill27-Jul-04 13:54
ASGill27-Jul-04 13:54 
GeneralRe: Automatically Display Expire Date Pin
Colin Angus Mackay28-Jul-04 0:31
Colin Angus Mackay28-Jul-04 0:31 
GeneralRe: Automatically Display Expire Date Pin
ASGill28-Jul-04 7:58
ASGill28-Jul-04 7:58 
GeneralRe: Automatically Display Expire Date Pin
Roman Rodov28-Jul-04 15:50
Roman Rodov28-Jul-04 15:50 
Questiondouble -&gt; float : casting or Convert.ToSingle ? Pin
crushinghellhammer27-Jul-04 13:13
crushinghellhammer27-Jul-04 13:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.