I am new to C# and trying to figure out how to make a function library in the same project as various screens, etc. (There will be a more generic function library in a different project).
At any rate, the very last line below is generating the error:
'cbiz.TemplateOneRec.xxx' denotes a 'field' where a 'class' was expected
The first chunk of code is the class, set second is the first few lines of form class I am trying to implement..
Can anyone see the problem and fix here
Many thanks
Mike Thomas
using System;
namespace cbiz
{
public class testString
{
string conn;
public teststring()
{
conn = "A character string";
}
public string GetString()
{
return conn;
}
}
}
**************
**************
using System;
namespace cbiz
{
public class TemplateOneRec : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
testString xxx = new testString();
/// problem line here
string connectionString = xxx.GetString();
........................

Error: denotes 'field' where a 'class' expected
VanDamMan
Two problems:
public teststring()
This needs to be testString, or the class won't compile.
string connectionString = xxx.GetString();
You can't call methods on non-static variables to initialise other member variables, you'd need to make this call in your constructor.
tomjanssen
Mike Thomas