The first C# example is very simple and illustrates the use of the .NET assembly with the C# programming language. The example is provided in the “TESTSAT/NET/EX01/readBdf.cs” source file. The compilation is done with the script “readBdf.bat”, which contains the following lines:
@SET FRP=../../../SRC/OUTPUTS/NET C:/Windows/Microsoft.NET/Framework/v3.5/csc.exe -platform:x86 \ -r:%FRP%/FeResPost.dll ..\UTIL\util.cs readBdf.cs readBdf.exe
(You may have to change the “%FRP%” path to the FeResPost .NET assembly before compiling the example.) Note also that version 3.5 of the .NET Framework is used here. This is not strictly necessary for this example, but it may be useful for some examples in which classes are extended with extension methods. Once the compilation is done, the compiled program is run with the line “readBdf.exe”.
The file “readBdf.cs” begins with several “using” directives:
using System; using System.Globalization; using System.Threading; using System.Collections.Generic; using FeResPost;
These directives shorten the type names used in the program. For example, the “using FeResPost” directive allows the “NastranDb” keyword to be used instead of “FeResPost.NastranDb”.
The first example is very simple and contains only one static “Main” function:
namespace ConsoleApplication1 {
class readBdf {
static void Main(string[] args) {
...
} // static void Main(string[] args)
} // class readBdf
} // namespace ConsoleApplication1
Note, however, that the static function is contained in a class. (C# does not allow a function to be defined outside of a class.) The “readBdf” class is also contained in a “ConsoleApplication1” namespace.
The other lines defining the program are very simple and can be considered “classical” C# programming:
NastranDb db = new NastranDb();
db.Name="tmpDB2";
db.readBdf("../../MODEL/MAINS/unit_xyz.bdf");
(The reader is referred to chapter III.1 for a description of the “readBdf” arguments.) Note that in the second call to “readBdf”, an empty “Dictionary” is used instead of a Ruby “Hash” object as the parameter.