Description
Microsoft has done an outstanding job documenting the .NET Framework and providing a wealth of examples. The majority of all the examples provided will show a developer in detail how to utilize the Framework or concept in question, that is if you're a VB or C# programmer! What about NetCOBOL? Well Fujitsu Software is working on creating samples and making them accessible to the general public. In the meantime however, what's a COBOL developer supposed to do to solve a problem you currently have?
In this article we'll take a look at some C# samples of code and then translate those samples into COBOL.This article is intended to be used as a model for you to follow when you run into a C# example and need to convert it to COBOL.
A really neat trick!
One of the brightest people I know of has assisted Fujitsu Software in creating a dual set of CD's titled "Microsoft .NET for COBOL Programmers". (This set of CD's is currently available from Fujitsu Software). The author of the CD's is Howard Hinman, President and CEO of Hinman Consulting. Howard had a very good suggestion that I used while learning the .NET environment, create a duplicate project in either VB.NET or C#. During your development phase, create an additional project in your solution using either of Microsoft's languages. Howard is more comfortable with VB so he chose VB.NET, I am more comfortable with C# so I use it.
What we both do however is create an additional project in our COBOL solution. If I am creating a WinForm application then I create another WinForm application in C#. As I am going through the COBOL development process if I have any questions on how a specific namespace is implemented I use the other language project to help me out. Now don't worry if you don't know C# at this point. You will only be using it to try and help determine what a certain objects method and properties are. In C# (and VB.NET) a feature called 'intellisense' has been implemented. Intellisense provides a programmer with additional information about an object when they are using that object. We'll get to more of this in a little bit.
Syntactical Differences
C# uses an OBJECT-DOT-PROPERTY syntax. The object in question may be a WinForm, a text box or any of the over 5,000 namespaces within the Framework. The key is when a developer presses the dot (.) . When the dot is pressed a context sensitive window appears showing the developer what options are available for that particular object. The window may contain other objects, properties or methods that are accessible to the object. Instead of remembering where a specific property or method is within an object, by using intellisense a developer can 'drill down' to the property or method they are looking for.
For instance, the following code shows intellisense for a command button object.

VS.NET is waiting for the developer to select an item or begin typing. When a developer begins typing intellisense will position the list based on the input. So instead of keying say 'Text', the developer would begin keying in 'T' and intellisense will move the list to show all items beginning with 'T'.





Sr KarthigaPosted Feb 14, 2016, 12:25 AM
Good one
Matthew FishereditedPosted Mar 19, 2010, 5:45 PMEdited Mar 19, 2010, 6:20 PM
I'm always in favor of converting C# to COBOL. Your zip file should make for hours of good coding entertainment. The $set ilusing directive is a nice trick. I also just saw Michael Bleistein's excellent article about COBOL's alternative methods for referencing types -- namely the ilusing directive, repository declarations, and the type keyword. I'd lightly rework the sample code as follows. The changes here are to: add some inherently hairy sample code in C++/CLI fix a few coding and formatting errors in the VB sample standardize variable names across languages take advantage of .NET's composite string formatting upgrade to terse, elegant, fixed-format COBOL outdent COBOL comments by one space for better visual alignment crack a few jokes Granted, the C++/CLI and COBOL examples are unnecessarily complicated by insisting on using HelloWorld::Main as the startup object. <?XML:NAMESPACE PREFIX = System /><System::String ^><System::String ^> // C# using System; namespace Hello { public class HelloWorld { public static void Main(string[] args) { string who = "C#"; if (args.Length > 0) { who = args[0]; } // Writing to the console is extremely tedious in C# ... Console.WriteLine("Hello, {0}!", who); } } } ' VB.NET Imports System Namespace Hello Class HelloWorld Overloads Shared Sub Main(ByVal Args() As String) Dim who As String = "VB.NET" If args.Length = 1 Then who = args(0) End If ' ... and equally tedious in VB.NET. Console.WriteLine("Hello, {0}!", who) End Sub End Class End Namespace // C++/CLI #include "stdafx.h" using namespace System; namespace Hello { class HelloWorld { public: static int Main(array<System::String ^> ^args) { String ^who = "C++/CLI"; if (args->Length > 0) { who = args[0]; } // Oh, the tedium of it all! Console::WriteLine(L"Hello, {0}!", who); return 0; } }; } static int main(array<System::String ^> ^args) { return Hello::HelloWorld::Main(args); } *> Finally some COBOL! $set ilusing"System" class-id. HelloWorld as "Hello.HelloWorld". static. method-id. Main. local-storage section. 01 who string value "COBOL". linkage section. 01 args string occurs any. procedure division using by value args. if args::"Length" = 1 move args(1) to who end-if *> COBOL can be tedious, if you insist ... invoke type "Console"::"WriteLine"("Hello, {0}!", who) *> ... but since 1959 has supported a more expressive style: display "Goodbye, " who "!" . end method Main. end static. end class HelloWorld. At the end of the day, only one of these languages is COBOL. </System::String></System::String></System::String></System::String>