Here is my current swap code for swapping 2 KeyValuePair objects in an array:
KeyValuePair<int, T> t = a[i];
a[i] = a[j];
a[j] = t;
Would there be any speed advantage to using unsafe code and merely swapping the pointers of the 2 objects? Or does the complier effectively boil this safe code down to effectively ...
I'm trying to create a new user on my development active directory server using .NET System.DirectoryServices namespace.
I try using the following code:
DirectoryEntry dirEntry = new DirectoryEntry(path, "TESTDOM\\Administrator", "2109password", AuthenticationTypes.Secure | AuthenticationTypes.ServerBind);
object o = dirEntry.NativeOb...
That is, I want to do this:
var lists = (from list in this.DB.Lists
select new
{
List = list,
Items = list.ListItems.ToList(),
}).ToList();
But, obviously, the Entity Framework doesn't support the ToList extension method in the select clause.
What should I do? ...
I have a type SearchBag that holds a bunch of strings and nullable integers to use for passing on search values. I need a way to check if the search bag contains any values.
I'm currently trying to do it like this:
public bool HasValues()
{
return GetType().GetProperties().Any(p => p.GetValue(this, null) != null);
...
When I save a jpg file using bitmap.save, it saves as jpeg 4-1-1 when I specify the encoder and quality, but as 4-2-2 when I don't. I would like to save it as 4-2-2 with a higher quality than the default. Is that possible using bitmap.save? Do I lose anything by saving with 4-1-1?
Dim bmp As Bitmap
Dim ep As New EncoderParameters(1)
Dim...
Quick question here, I'm using Visual Studio to create an Outlook add-in. I've created the code and it boots up nicely in Outlook. Now to actually creating an installer.. This is what I've done so far, created a new installer project and added the files (dll and vsto) from the debug folder of the actual outlook project. But when I build ...
Hello,
Is there a way to take a chuck of msil code saved as a byte stream and reverse engineer it to some higher level code (e.g. C#)?
Edit: MSIL instructions that are not a whole assembly
Thanks,
Jon
...
A few friends and myself have been working on an XNA RPG once a week for the last year. Our battle engine is basically finished, and now we're working on overworld exploration.
I've already created crude Tile and TileMap objects that work in this way:
Simple 2D array of integer values representing tile (Texture2D) objects in a List
Us...
This may be seen as a duplicate of http://stackoverflow.com/questions/3423248/thread-safety-lists-binding-and-wpf, but I post it anyway since I'm not fully happy with the accepted response, and I might be able to express what I suspect is the same question more exactly.
Any operations related to UI in WPF/Silverlight must be performed o...
Is there a doubleclick event for a datagrid? I'm trying to use this code to open a details form when the user doubleclicks on a row.
http://www.codeproject.com/KB/grid/usingdatagrid.aspx
I tried adding it by doubleclicking on the control, but it gives dataGrid1_Navigate instead.
...
I have an Excel plug-in (written in C#) with a static variable that is at the heart of a singleton data cache:
static DataCache _instance;
This is accessed via three different code paths:
Event handlers on a VSTO ribbon-bar initialize the instance, and also read it for display in helper dialogs
An RTD server (a class that is declare...
So situation is following:
We have some very old product, that has dozen of solutions. Many of them run different unit tests, some MSTest, some NUnit. There are lot of tests that test database, also some depend on data. In other words they execute code to check if customer Andriy has orders with products A and B. I know that this is wron...
I have an entity 4.0 model that is using a SqlServerCE database as its provider. On the server I want to use the same project and just switch out the connection string to use the actual SqlServer database.
Here is my connection string
<add name="Entities"
connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|re...
I have a form with a rich text box control. Is there a way to have caps lock turn on whenever the rich textbox control has focus? And turn it off if the rich text box loses focus? I am using C#
...
Hi
When I'm reading this tutorial I noticed the following performance tip about using structs in C#:
Unless you need reference type
semantics, a class that is smaller
than 16 bytes may be more efficiently
handled by the system as a struct.
I looked for similar question in stackoverflow but I found some questions that talks a...
Using this, I can tell Fluent NHibernate to use SysCache as a 2nd Level Cache Provider:
MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(x =>
{
x.Server(@"localhost\ANDREPC");
x.Database("mydb");
x.TrustedConnection();
}).Cache(c => c.ProviderClass<SysCachePr...
Hi everyone, I trying to use apns-csharp library to send push notification from .NET, I created certificate on Apple Provision Portal, download it and convert to p12 format, when i try to load it with code:
private ActionResult SendAlertPushNotification(string appId, string notificationContent, bool useSandBox)
{
Not...
I want to run a custom logic, before the page life-cycle, to decide what version of a cached page I want to serve to the user.
Example:
If the user is not logged, then I go to a cache dictionary, catch a version A of the page and serve to the user. Otherwise, if it's logged, then I'll see if I already cached a version of the page sp...
I'm calling a service reference using WCF, but the service requires plain-text passwords, which WCF does not natively support, so I'm using Yaron Naveh's ClearUsernameBinding implementation. This is getting me half the way there. The service I'm calling is firing (because I can see it insert records into a database), but it's failing on ...
Hi!
Why those languages are case-sensitive? I've become curious because I was reading the differences between VB.NET and C Sharp, and VB.NET is not case-sensitive. And I think this way is better, because case-sensitive can only be a source of bugs and bad code. Bad code because there's no reason to have variable's names that differ only...