Questions tagged [language-specifications]

126 questions
0
votes
3 answers

Why does an extension method bypass the need for explicit conversion?

I have an explicit conversion setup between two reference types. class Car { public void Foo(Car car) { } public static explicit operator Bike(Car car) { return new Bike(); } } class Bike { } If I invoke Foo…
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
-1
votes
2 answers

Question on object lifetime : N3242 Draft

A point from C++11 n3242 "Duration of subobjects, object lifetime", 3.8/1: The lifetime of an object is a runtime property of the object. An object is said to have non-trivial initialization if it is of a class or aggregate type and it or one…
user751747
  • 1,129
  • 1
  • 8
  • 17
-1
votes
1 answer

C# Reference Type alternatives to Value Types

I know there are different posts related to questions around this topic, but I couldn't find any source on the question I have. In some scenarios, it would be much easier, if value types behaved as reference types, i.e. they could be modified inside…
David Oganov
  • 976
  • 1
  • 11
  • 23
-1
votes
3 answers

Why Can't I Specify The Size Of The Array Returned From A C# Function?

I know that the following C# code will not compile: int[10] TestFixedArrayReturn(int n) { return new int[10]{n, n, n, n, n, n, n, n, n, n}; } void TestCall() { int[10] result = TestFixedArrayReturn(1); } In order to get it to compile, I need…
Onorio Catenacci
  • 14,928
  • 14
  • 81
  • 132
-1
votes
5 answers

What is the origin of CS0060:The direct base class of a class type must be at least as accessible as the class type itself

I just ran into this basic rule about inheritance in .net: CS0060:The direct base class of a class type must be at least as accessible as the class type itself I'm curious why this rule was developed. Does anyone know why this kind of inheritance is…
mohammed sameeh
  • 4,711
  • 3
  • 18
  • 19
-3
votes
1 answer

type inference not working in several declaration cases

why the following statement is perfectly valid one string a = "someString", b = a, c = a; but this one does not compile var a = "someString", b = a, c = a; another example is here first, an error: second OK: I've seen a similar question here,…
serge
  • 13,940
  • 35
  • 121
  • 205
1 2 3
8
9