java marune bn

wissnshaftler

Well-known member
  • Dec 13, 2023
    6,575
    10,848
    113
    JavaScript වල එහෙමත් පුලුවන් class එකක් නැතුව object එකක් හදන්න
    මේකට හේතුව js ඇවිල්ල ප්‍රොටොටෛප් ඔරිඑන්ටඩ් නේද ? හැබැයි සිරාම ගත්ට්තොහ් ඔබ්ජෙක්ට් ගහන්න නං ක්ලාස් ඔනෙ නේඩ්ග
     

    EKGuest

    Well-known member
  • Nov 16, 2022
    3,206
    5,703
    113
    මේකට හේතුව js ඇවිල්ල ප්‍රොටොටෛප් ඔරිඑන්ටඩ් නේද ? හැබැයි සිරාම ගත්ට්තොහ් ඔබ්ජෙක්ට් ගහන්න නං ක්ලාස් ඔනෙ නේඩ්ග

    මම IT Field එකේ නෙමෙයි ගොඩක් ලැන්වේජස් ගැඹුරට ඉගෙනගෙන නෑ වැඩිපුර C# තමයි කරලා තියෙන්නේ.

    හැබැයි JavaScript වලත් ක්ලාස් එකක් ඩිෆයින් කරලා ඒකේ instances විදියට ඔබ්ජෙක්ට්ස් හදන්න පුලුවන්. (ඒත් වැඩිය පාවිච්චි වෙන්නෙ නෑ මම හිතන්නේ)

    C# වලනම් ක්ලාසස් පාවිච්චි කරනවා ඔබ්ජෙක්ට්ස් හදන්න. (E.g. Customer table in the database can be represented by Customer class in your program). C# වල ගොඩක් anonymous types ප්‍රයෝජනවත් වෙනවා LINQ queries ලියනකොට. (E.g. when Customer has Name, Age, and Address properties but you only want to get Name and Address. It is easier to use anonymous types in that case than to create a new class)

    var customerContacts = customers.Select(customer => new { customer.Name, customer.Address });
     
    • Love
    Reactions: wissnshaftler