Questions tagged as 'c#'

5
answers

Why wear shorts?

The type short corresponds to a 16-bit integer - it is literally syntactic sugar for type Int16 . Current processors are all 64 bits, even on most low-end machines. Some older machines still have processors with 32-bit architectu...
asked by 25.04.2014 / 00:21
3
answers

Why does C # not allow multiple inheritance?

In C # we can implement several interfaces. But why can not we inherit from more than one base class?     
asked by 31.01.2014 / 18:58
4
answers

How to pass string by reference?

I passed a string as a parameter. From what I know it is passed by reference, so if I change anything in it within the method, when I leave it the value will continue to change. I did the test below and it did not happen what I expected. Am...
asked by 31.03.2017 / 13:21
3
answers

Write TimeSpan in full

I want to write a static class (can be Extension ) to represent the value of a structure TimeSpan " in full, in Portuguese. The idea is to always compare the current date ( Datetime.Now ) with the date that the event occurred....
asked by 24.08.2015 / 19:26
4
answers

Should I use GUID or int as a primary key?

I'm about to start a new project in MVC 4 with Entity Framework, searching I found several examples here in the SOpt of models that use GUID as ID and some doubts have arisen: What is the advantage of using GUID as a primary key? Is it feas...
asked by 19.06.2014 / 21:38
3
answers

foreach is a loop or iterator? Or could it be both?

In a video tutorial the instructor said not to fall into foolish to think that the foreach loop is one, and was vehement that he was an iterator. There are cases where we can scroll through the items in an array using foreach as a "compact fo...
asked by 05.03.2017 / 23:34
1
answer

Compiler Roslyn - What is it, and why was it created?

What is the Roslyn compiler? Is this the default Visual Studio compiler? Is it open source? Why did they do this? Only for C # or other languages as well?     
asked by 26.08.2015 / 22:08
2
answers

What is the "?." operator?

I'm seeing the functions that C # 6.0 brought, and an example of code appeared: C # 5.0 var vendor = new Company(); var location = default(string); if (vendor != null) if (vendor.ContactPerson != null) if (vendor.ContactPerson.HomeAdd...
asked by 11.10.2015 / 03:26
2
answers

What is serialization? When to use? How to implement in C #?

[Serializable] public class Pessoa { public string Nome { get; set; } public string Cpf { get; set; } } Is there only one kind of serialization ? What are the alternatives for not needing serializing an object?
asked by 15.04.2014 / 22:59
4
answers

Why use C # extension methods?

What do I get with extension methods that I do not gain with inheritance? Simply using it as if it had the same name is tricky, since it causes more confusion than anything else.     
asked by 24.06.2016 / 13:43