Skip to main content

Is there an equivalent in .net Cobol to C#'s string interpolation?  For example:

int cats = 100; int dogs = 2;

string animals = $"cats = {cats} and dogs = {dogs}";

I know that I can use string::format but was wondering if string interpolation exists.

Is there an equivalent in .net Cobol to C#'s string interpolation?  For example:

int cats = 100; int dogs = 2;

string animals = $"cats = {cats} and dogs = {dogs}";

I know that I can use string::format but was wondering if string interpolation exists.

It appears that Microsoft added this feature with C# version 6.0 and Visual Studio 2015, correct?

Is there an equivalent in .net Cobol to C#'s string interpolation?  For example:

int cats = 100; int dogs = 2;

string animals = $"cats = {cats} and dogs = {dogs}";

I know that I can use string::format but was wondering if string interpolation exists.

Yes, I do believe so.

Is there an equivalent in .net Cobol to C#'s string interpolation?  For example:

int cats = 100; int dogs = 2;

string animals = $"cats = {cats} and dogs = {dogs}";

I know that I can use string::format but was wondering if string interpolation exists.

We don't currently have an equivalent in COBOL. However you can use a concatenation expression as an alternative to string::format, e.g.

declare cats as binary-long = 100
declare dogs as binary-long = 2
declare animals as string = "cats = " & cats & " and dogs = " & dogs
display animals