M
markus wolfgart
Hi NG,
I would like to create a struct of mixed content
of dynamic data and constant data like below:
public struct PFD_Order_T
{
// key names of order_file // constant content
public const string key_order_id = "order_id";
// content of order file // dynymic content
public string order_id;
}
When compiling this structure with vs2005 I get no errors.
When defining a class with a structured data like above
public partial class Form1 : Form
{
PFD_Order_T PfdOrder;
....
}
and creating some functions/procedures which use PFD_Order_T as
input Parameters (second function)
public partial class Form1 : Form
{
PFD_Order_T PfdOrder;
private string extract_from_order_line(string line, string key)
{
if (line.Contains(key))
{
int index = line.IndexOf(key);
index++; // skip "="
return line.Substring(index, line.Length - index);
}
return null;
}
private void parse_order_file(string filename, PFD_Order_T pfdorder)
{
string[] fileLines = SplitFileByLine(filename,"\r\n");
string fileLine = "";
for (int index = 0; index < fileLines.Length; index++)
{
fileLine = fileLines[index].Trim();
pfdorder.order_id =
extract_from_order_line(fileLine,pfdorder.key_order_id); <=== My problem
...
}
}
}
I could not select my constant part of my struct like I demonstrate
above. Means pfdorder.key_order_id is for me not visible in vs2005 where
as pfdorder.order_id could be selected.
Any hints whats wrong with my definition of the struct PFD_Order_T.
The idea behind this constellation of abstract data is to have a
unchanged part of data like an item and the corresponding dynamic
data. I will use this for parsing a file in order to extract a value
located behind the item defined in .key_order_id.
Many thanks in advance for your help
Markus Wolfgart
I would like to create a struct of mixed content
of dynamic data and constant data like below:
public struct PFD_Order_T
{
// key names of order_file // constant content
public const string key_order_id = "order_id";
// content of order file // dynymic content
public string order_id;
}
When compiling this structure with vs2005 I get no errors.
When defining a class with a structured data like above
public partial class Form1 : Form
{
PFD_Order_T PfdOrder;
....
}
and creating some functions/procedures which use PFD_Order_T as
input Parameters (second function)
public partial class Form1 : Form
{
PFD_Order_T PfdOrder;
private string extract_from_order_line(string line, string key)
{
if (line.Contains(key))
{
int index = line.IndexOf(key);
index++; // skip "="
return line.Substring(index, line.Length - index);
}
return null;
}
private void parse_order_file(string filename, PFD_Order_T pfdorder)
{
string[] fileLines = SplitFileByLine(filename,"\r\n");
string fileLine = "";
for (int index = 0; index < fileLines.Length; index++)
{
fileLine = fileLines[index].Trim();
pfdorder.order_id =
extract_from_order_line(fileLine,pfdorder.key_order_id); <=== My problem
...
}
}
}
I could not select my constant part of my struct like I demonstrate
above. Means pfdorder.key_order_id is for me not visible in vs2005 where
as pfdorder.order_id could be selected.
Any hints whats wrong with my definition of the struct PFD_Order_T.
The idea behind this constellation of abstract data is to have a
unchanged part of data like an item and the corresponding dynamic
data. I will use this for parsing a file in order to extract a value
located behind the item defined in .key_order_id.
Many thanks in advance for your help
Markus Wolfgart