Merging two arrays in .NET

If you can manipulate one of the arrays, you can resize it before performing the copy: Otherwise, you can make a new array More on available Array methods on MSDN.

I got error “The DELETE statement conflicted with the REFERENCE constraint”

The error means that you have data in other tables that references the data you are trying to delete. You would need to either drop and recreate the constraints or delete the data that the Foreign Key references. Suppose you have the following tables Suppose a Foreign Key constraint exists between the StudentTypeId column in StudentTypes and the StudentTypeId column in Students … Read more

“Invalid JSON primitive” in Ajax processing

Just a guess what does the variable json contain after If it is a valid json object like {“foo”:”foovalue”, “bar”:”barvalue”} then jQuery might not send it as json data but instead serialize it to foor=foovalue&bar=barvalue thus you get the error “Invalid JSON primitive: foo” Try instead setting the data as string This way jQuery should leave the data alone and send the … Read more

Task vs Thread differences

Thread is a lower-level concept: if you’re directly starting a thread, you know it will be a separate thread, rather than executing on the thread pool etc. Task is more than just an abstraction of “where to run some code” though – it’s really just “the promise of a result in the future”. So as … Read more

What is the C# equivalent of friend?

There’s no direct equivalent of “friend” – the closest that’s available (and it isn’t very close) is InternalsVisibleTo. I’ve only ever used this attribute for testing – where it’s very handy! Example: To be placed in AssemblyInfo.cs

Categories c# Tags

What does ModelState.IsValid do?

ModelState.IsValid indicates if it was possible to bind the incoming values from the request to the model correctly and whether any explicitly specified validation rules were broken during the model binding process. In your example, the model that is being bound is of class type Encaissement. Validation rules are those specified on the model by the use … Read more

entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1

Because these two lines … … don’t take a parameter in the constructor, I guess that you create a context within the classes. When you load the city1… …you attach the city1 to the context in CityService. Later you add a city1 as a reference to the new Employee e1 and add e1 including this reference to city1 to the context in EmployeeService. As a result you have city1 attached to … Read more