Convert C# is Operator to instanceof Operator in Java
2 posts in topic
Thread View Thread View
TOPIC ACTIONS:
 

Convert C# is Operator to instanceof Operator in J...
zarfishan
Sun Jun 24, 2012 09:06 PM

 

 

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 met:

·          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 ;

 

// ********* THIS FILE IS AUTO PORTED FORM C# USING CODEPORTING.COM *********

 

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.

  namespace CsPorter. ...

praveenkumar2011
Wed Aug 22, 2012 06:56 AM

			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
			;
			}
			}
			
				}
				http://www.mmenterprises.co.in/
			
		

Hello Friends 
M M Enterprises

  Normal 0 false false...

johny2211
Sun Sep 09, 2012 04:05 AM

Normal 0 false false false MicrosoftInternetExplorer4 <![endif]--> <![endif]-->

Hi

     I am johny, it is a good question, but I can’t help you for the solution

  of this question, But u can get a good solution from this site,

  so always in touch with this site,,,,

-------------------------------------------------------------------------------------------

  [url= http://www.jeetmaths.co.cc ] Conics sections [/url]

 

 

About | Sitemap | Contact