Naming convention rules: Id in plural [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a question about C# naming convention rules.
I know that you write ex. CustomerId.
But what if it the property is a List of CustomerId's?
Should I write CustomerIds or CustomerIdS?

MSDN describes using pascal casing for member names. There is no specific guideline on plurals as far as I can see, but I would suggest CustomerIds since it feels more natural to me.
Also here the question between ID and Id is answered: use Id.

Related

Are we supposed to use properties or private fields in Blazor code behind classes? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
In Blazor, certain things like injected objects and parameters must use properties, that part is clear.
But what about those page-specific variables, such as data/DTOs and misc strings/booleans etc used to control the page content and flow?
Is it better to use automatic properties with these all the way (public or private?) or private fields?
I'm asking this because in the various examples, tutorials and documentations related Blazor, use of both properties and fields are all over the place. I cannot seem to find any official best-practice guides on this.

Should Dto contains full information of reference object? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Let assume I have two entities are Order and Customer. So OrderDto should have CustomerId prop or full Customer object. The same with CustomerDto, should they have full list Order object or just a list of OrderId?
I think that it depends what you're using it for. The DTO should be specific to the needs of the api, not the Entities. For example if you're creating an order, you don't need to modify any properties of the customer. You shouldn't include the full customer details, just the CustomerId.

Define constants needed in more than one class [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
In my smart client solution, I have a Project folder with:
IProjectView.cs
*ProjectView*
ProjectView.cs
ProjectView.Designer.cs
ProjectView.GeneratedCode.cs
ProjectView.resx
ProjectViewPresenter.cs
I want to define some constants for user by ProjectView.cs and ProjectViewPresenter.cs. Both of these classes implement IProjectView.cs, so were I back in Java, I'd put them there. If this were C++, I'd create a class ProjectConstants.cs and have the classes inherit it, but C# doesn't allow multiple inheritance.
How do I do this?
Can having a Read-Only Property in your interface solve your problem?
string MyReadOnlyProperty { get; }
I have no clue if this is very performance-wise compared to constant thought.

Best way to transmit bool with attribute routing [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Is there any good example of the transmission bool parameter with attribute routing?
For example I can transform route
{controller}/{action}?param=true
to
{controller}/{action}/param=true
but it still "dirty".
Sorry for dummy question (:
Solution is use two attribute like this:
[Route("ValuesForFalse/{param=false}")]
[Route("ValuesForTrue/{param=true}")]
you can use like this
{controller}/{action}/{param}
param is bool

What is the best use of a variable when required by multiple methods [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm using XmlManager to
do xml manipulations in several methods in a class.where I should declare XmlManager variable ?
1.locally within each method and do intialization.
2 declare at globally and initiate at the method level
As it is, in this question, there's absolutely NO difference whatsoever because there's neither performance gain nor significant design issues.
Maybe if the question is put into context there could be reason to choose one approach over the other, but as it stands now. None of the approach is better than the other one

Categories

Resources