C#でのキーワードの使用は何ですか?
例
using System;
namespace DemoApplication{
class Program{
static void Main(){
Employee emp = new PermanentEmployee{
ID = 1,
Name = "Martin"
};
// Returns true as the derived type can be converted to base type.
if (emp is Employee){
Console.WriteLine(emp.Name + " is Employee");
}
else{
Console.WriteLine(emp.Name + " is not Employee");
}
//Returns true, as the actual object is of type PermanentEmployee.
if (emp is PermanentEmployee){
Console.WriteLine(emp.Name + " is PermanentEmployee");
}
else{
Console.WriteLine(emp.Name + " is not PermanentEmployee");
}
//Returns false, as PermanentEmployee object cannot be converted to
//ContractEmployee.
if (emp is ContractEmployee){
Console.WriteLine(emp.Name + " is ContractEmployee");
}
else{
Console.WriteLine(emp.Name + " is not ContractEmployee");
}
}
}
class Employee{
public int ID { get; set; }
public string Name { get; set; }
}
class PermanentEmployee : Employee{
public int AnnualSalary { get; set; }
}
class ContractEmployee : Employee{
public int HourlySalary { get; set; }
}
} -
C#でのsizeofOperatorの使用は何ですか?
sizeof()データ型は、データ型のサイズを返します。 intデータ型のサイズを見つける必要があるとしましょう- sizeof(int); 二重データ型の場合- sizeof(double); さまざまなデータ型のサイズを見つけるための完全な例を見てみましょう- 例 using System; namespace Demo { class Program { static void Main(string[] args) { Console.Wr
-
Java 9でのアンダースコアキーワードの使用は何ですか?
以前のバージョンのJavaでは、アンダースコア ( _ )は識別子として使用されています または変数を作成します 名前 。 Java 9以降、アンダースコア 文字は予約キーワードです 識別子または変数名として使用することはできません。単一のアンダースコアを使用する場合 キャラクター 識別子として、プログラムはコンパイルに失敗し、コンパイル時エラーをスローします 今はキーワードだからです Java 9では変数名として使用できません 以降のバージョン。 例 public class UnderscoreKeywordTest { public static void