|
|
Hm, so when do you use this? Feels like everything I thought my students about private variables and getters and setters is obsolete...
Here´s something to put in my signature.
The more I learn the more I realize how little I know...
|
|
|
|
|
It doesn't replace the property stuff at all. In fact, this syntax uses those properties. The syntax change is just "shortcut sugar" to avoid having to new up the type and then add a bunch of code to set the properties in multiple statements.
|
|
|
|
|
It's just syntactic sugar designed to reduce the amount of code you type. It doesn't render any of your previous knowledge obsolete, it's just that it's easier to read something like this:
Movie movie = new Movie
{
Name = "Batman vs Superman",
ReleaseYear = 2016,
Rating = 4.5
} Than it is to read this:
Movie movie = new Movie();
movie.Name = "Batman vs Superman";
movie.ReleaseYear = 2016;
movie.Rating = 4.5; It also means you don't have to provide multiple overloaded constructors if you're just providing properties that you want to populate. I don't want to blow your mind, but you can extend this concept to also include collection initialisation as well. Suppose you added a list of actors to your class, you can initialise it like this:
Movie movie = new Movie
{
Name = "Batman vs Superman",
ReleaseYear = 2016,
Rating = 4.5,
Actors = new List<string> { "Ben Afleck", "Jessie Eisenberg", "Gal Gadot", "Henry Cavill" }
};
This space for rent
|
|
|
|
|
No; It's already available in c# language called as object initializer.
for eg :- Student objstd=new Student(){
Name ="Surya",
roll=112,
Adress="Hyd"
};
So it's available in net framework version 3.0 on word.
|
|
|
|
|
How can I copy present address to permanent address using checkbox,when I checked checkbox present address must copy to permanent address in mvc5
|
|
|
|
|
Try posting the code that you are having problems with - it might help us understand your question
|
|
|
|
|
Ummm....WHAT??
"Present address"?? "permanent address"?? How does a checkbox relate to this?
You've failed to provide any context at all and now definitions for these terms. It's pretty much impossible to help you until you do.
|
|
|
|
|
You'll either need JavaScript to hook up the checkbox "checked" event with the copy operation on the client side; or check the value of the checkbox in the controller code on the server and do the copy there.
|
|
|
|
|
Through the magic of ViewModels!
public ActionResult DoMyThing(MyViewModel vm)
{
if (vm.ChangeAddressFoo)
{
vm.PermanantAddress.CopyMethod(vm.PresentAddress);
_context.MyRepoUpdateMethod(vm.PermanantAddress);
return Json(new{Change = true})
}
return Json(new{Change = false})
}
Actual implementation has been concealed to protect the innocent.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
need to write a C# code that can execute any stored procedure by just making configuration
|
|
|
|
|
Okay, you have a high level requirement. You are now going to need to break that down into lower level requirements and keep refining these requirements until you reach a point where you can come up with a design. Here are some things you might want to consider.- Do your stored procedures need to run inside transactions?
- Can they return data or are they execution only?
- Can they accept tables?
- How is the application going to know that it needs to call a particular procedure?
- How are you going to map from code to parameters from your stored proc?
- Do the procedures need to be retriable?
There are many other questions you are going to have to ask, but this is a good start.
This space for rent
|
|
|
|
|
Thanks Pete
- I don't require the transactions as we have already implemented within the procedures.
- No need to provide the tables
- The major requirements is that it can accept any number of parameter OR without parameter.
- The procedure can be capable of executing and return data both
|
|
|
|
|
So keep refining those requirements. That should help you drive out the design. Don't forget that I only gave you some things to consider there, there will be many, many others.
This space for rent
|
|
|
|
|
Error in global.asax
|
|
|
|
|
Yeah, there's really no answer to your "question" because that's not the complete error message. It's impossible to tell you what's wrong because there's more than just a couple of lines of code in Global.asax.
|
|
|
|
|
divyashasha wrote: Error in global.asax Yes.
Since there are over 42,131,343 possible error messages, would you be so kind as to specify which error message you are getting? It's Friday and I'm in no mood for guessing games.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
RyanDev wrote: I'm in no mood for guessing games. And I was just going to ask, "what is the difference between a duck?".
|
|
|
|
|
Richard MacCutchan wrote: what is the difference between a duck? A duck and what!?! You didn't finish!
Oh, wait, you got me.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Violation of PRIMARY KEY constraint 'PK__Registra__1788CC4C180CE6D9'. Cannot insert duplicate key in object 'dbo.Registration'. The duplicate key value is (0).
The statement has been terminated.
This is an Mvc 4 razor
|
|
|
|
|
Actually it's a database issue.
|
|
|
|
|
Means there already is a record with id '0' in the database. If it is not an auto-incrementing field, you might need a way to get the last and increment it. If it is a new application, then it may be easier to change the type of the field to a GUID and put a freshly generated GUID in there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This may sound crazy but I have many copies of a .net project's source code in source control but am trying to figure out which copy of the source code in the version control system is the correct code that was used to build the currently deployed production application's projects. The application was deployed several years ago and we have several versions of the source code but don't know which version in source control matches the actual production's code. I have read about reflector but was wondering if there was a more simple was to go. Can anyone help?
modified 24-May-16 12:39pm.
|
|
|
|
|
Can't unless you adhered to a rational software lifecycle pattern and it sounds like you (or they?) didn't. Look for a branch or a label or something that might give a clue. Which version control system?
|
|
|
|