copied code snippet from java api to dotnet api