Skip to content

Instantly share code, notes, and snippets.

@codeporting-com-gists
Last active May 6, 2019 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeporting-com-gists/4e51b0d4f03e1acaf3b4156ae7ba05f6 to your computer and use it in GitHub Desktop.
Save codeporting-com-gists/4e51b0d4f03e1acaf3b4156ae7ba05f6 to your computer and use it in GitHub Desktop.
Codeporting-Cs2Cpp-code
C# source code
public class IntEnumerator : IEnumerator<int>
{
public int Current
{
get
{
return 0;
}
}
object System.Collections.IEnumerator.Current
{
get
{
return Current;
}
}
public void Dispose()
{
}
public bool MoveNext()
{
return false;
}
public void Reset()
{
}
}
public class IntComparer : IComparer<int>
{
public int Compare(int a, int b)
{
return (a < b) ? -1 : (a == b) ? 0 : 1;
}
}
public class StringEnumerator : IEnumerator<string>
{
public string Current
{
get
{
return "StringEnumerator";
}
}
object System.Collections.IEnumerator.Current
{
get
{
return Current;
}
}
public void Dispose()
{
}
public bool MoveNext()
{
return false;
}
public void Reset()
{
}
}
public class StringOrdinalComparer : IComparer<string>
{
public int Compare(string a, string b)
{
return string.Compare(a, b);
}
}
C# source code
using System;
using NUnit.Framework;
namespace SampleCsProject.Attributes
{
[TestFixture]
class PortConstStringAsWCharTest
{
const string WCharValueByConfig = "def";
}
}
C# source code
using System;
using NUnit.Framework;
namespace SampleCsProject.Attributes
{
namespace UsingViaConfig
{
public delegate TResult Func<out TResult>();
public delegate TResult Func<in T, out TResult>(T arg);
public delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
}
}
C++ source code
class StringEnumerable : public System::Collections::Generic::IEnumerable<System::String>
{
public:
System::SharedPtr<System::Collections::Generic::IEnumerator<System::String>> GetEnumerator()
{
//...
}
};
class GetSetClass : public System::Object
{
private:
int32_t i;
};
C# source code
public class StringEnumerable : IEnumerable<string>
{
public IEnumerator<string> GetEnumerator()
{
//...
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
class GetSetClass
{
private int i;
public int someProperty
{
get
{
return i;
}
set
{
i = value;
}
}
}
C++ source code
#include <system/string.h>
#include <cstdint>
int32_t IntEnumerator::get_Current() const
{
return 0;
}
bool IntEnumerator::MoveNext()
{
return false;
}
void IntEnumerator::Reset() { }
int32_t IntComparer::Compare(int32_t a, int32_t b) const
{
return (a < b) ? -1 : (a == b) ? 0 : 1;
}
System::String StringEnumerator::get_Current() const
{
return L"StringEnumerator";
}
bool StringEnumerator::MoveNext()
{
return false;
}
void StringEnumerator::Reset() { }
int32_t StringOrdinalComparer::Compare(System::String a, System::String b) const
{
return System::String::Compare(a, b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment