Swapnil Joshi

Swapnil Joshi

  • NA
  • 1
  • 586

How to convert following code of C++ in C#

Mar 8 2016 12:16 AM
public:
virtual HRESULT GetOption(int SlotIndex)
{
HRESULT hr = S_OK;
CString strOpts;
CString Slot;
int Pos=0;
Slot.Format(_T("%d"), SlotIndex);

CString Module1 = "M" + Slot;
hr = io.QueryString(_T("DIAGnostic:SYSTem:MODule:PNUMber?"),strOpts);
strOpts.Remove('\"');
if(strOpts == "M8195A")
{
ModuleName = "M8195A";
}
else
{

hr = io.QueryString(_T("*OPT?"), strOpts);
if (SUCCEEDED(hr))
{
strOpts.Replace('\)', '\,');
strOpts.Remove('\(');
strOpts.Remove('\)');
strOpts.Replace('-', '.');
if(strOpts.Find(Module1) == -1)
{ModuleName = "";
return hr;}
else
{
Pos = strOpts.Find(Module1);
ModuleName = strOpts.Mid(Pos+3, 6);
}

}
}
return hr;
}

Answers (1)