How about this?:
using System.Linq;
namespace DW_411760_CS_CON
{
class Program
{
static void Main(string[] args)
{
string s1 = "Ui";
string s2 = "uk";
string s3 = new string((s1 + s2).ToLower().Distinct().ToArray());
}
}
}
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
I would do it sort of like this:
#pragma once
using namespace System;
using namespace System::Collections::Generic;
using namespace System::Linq;
namespace DW_411760_CPP_LIB {
public ref class CProgram
{
public:
static String^ MergeString(String^ s1, String^ s2)
{
String^ s3 = gcnew String(
Enumerable::ToArray(Enumerable::Distinct((s1+s2)->ToLower())));
return s3;
}
};
}
...and then you can call it from the C# program:
using System.Linq;
using DW_411760_CPP_LIB;
namespace DW_411760_CS_CON
{
class Program
{
static void Main(string[] args)
{
string s1 = "Ui";
string s2 = "uk";
string s3 = new string((s1 + s2).ToLower().Distinct().ToArray());
string s4 = CProgram.MergeString(s1, s2);
}
}
}
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
In order to make that work, you will need to change the C# project to the highest dot net level and add a new C++ project as a Class Library.
You will then need to add a refrence from inside the C# project to the C++ project, add the necessary code and compile.
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
I did edit that post.
I DO assume this thread should be marked solved unless the OP is not into my flavor of C++.
If not, the concept is the same: neutralize the case and remnove duplicates.
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402