Highlighted
Contributor.
Contributor.
813 views

.net Cobol String Interpolation

Jump to solution

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.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .net Cobol String Interpolation

Jump to solution
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

View solution in original post

0 Likes
3 Replies
Highlighted
Honored Contributor.
Honored Contributor.

RE: .net Cobol String Interpolation

Jump to solution
It appears that Microsoft added this feature with C# version 6.0 and Visual Studio 2015, correct?
0 Likes
Highlighted
Contributor.
Contributor.

RE: .net Cobol String Interpolation

Jump to solution
Yes, I do believe so.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .net Cobol String Interpolation

Jump to solution
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

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.