www.digitalmars.com         C & C++   DMDScript  

c++.announce - Convert C# =?UTF-8?B?4oCcaXPigJ0=?= Operator to

CodePorting Provides a cloud based conversion service to help 
users to automatically translate their source code from C# to 
Java using C#2Java Engine and because it is a web-based 
application that makes it platform, operating system and browser 
independent. You just need a browser and internet connection, no 
installation is required just Sign In and start converting your 
code from C# to java. You can also edit your .Net code on the fly 
and download your converted code from anywhere , anytime.

In my previous blog I showed you how CodePorting Engine converts 
Comments while translating C# code to java. This week I am going 
to show you how can convert C# “is” operator to java 
“instanceof” operator using Codeporting’s cloud based App.

An ‘is‘ expression returns true if following conditions are 
•	expression is not null
•	expression can be cast to type

Following Example shows how “is” operator will be converted 
to “instanceof” operator after the conversion.

C# Code:

namespace CsPorter.Examples.Convert.LanguageConstructs.AsIs
     public class Example1
         void Method()
             object obj = null;
             bool b = obj is string;
             b = b is object ? true : false;

Java Code:

package CsPorter.Examples.Convert.LanguageConstructs.AsIs;


public class Example1
     private void method()
         Object obj = null;
         boolean b = obj instanceof String;
         b = (Object)b instanceof Object ? true : false;

It is clear from the above example that Codeporting Engine 
automatically convert “is” operator to “instanceof” 
operator generating the same result.
Jun 24 2012