Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# questions: What type of methods can be called without instantiating an object first? static dynamic primary Assume an extension method is defined as: static

C# questions:

What type of methods can be called without instantiating an object first?

static
dynamic
primary

Assume an extension method is defined as:

static class Util

{ public static int Negate(this int i)

{

return -i;

}

}

Which of the following is correct?

int x = 591;

Console.WriteLine($"x.Negate {x.Negate()}");

int x = 591;

Console.WriteLine($"x.Negate {Util.Negate(x)}");

both A and B
None of the above

To define an extension method for a type:

The extension method can be an instance method
The first parameter must be of the type being extended
The first parameter must be proceeded by this keyword
Both A, B and C

Both B and C

Both A and C

var addresses = new[] {

new { CompanyName = "Alpine Ski House", City = "Berne", Country = "Switzerland"},

new { CompanyName = "Coho Winery", City = "San Francisco", Country = "United States"},

new { CompanyName = "Wingtip Toys", City = "London", Country = "United Kingdom"},

new { CompanyName = "Wide World Importers", City = "Tetbury", Country = "United Kingdom"}

};

var usCompanies =

addresses.Where(addr => String.Equals(addr.Country, "United States"))

.Select(usComp => usComp.CompanyName)

What type is variable usCompanies?

int
string
IEnumerable
anonymous type

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago

Question

=+2 Why are so many countries bothered by their brain drains?

Answered: 1 week ago