I read http://stackoverflow.com/questions/90838/how-can-i-detect-the-encoding-codepage-of-a-text-file
It's not possible to detect encoding. However is it possible to detect whether encoding is one of two allowed?
For example I allow user to use Unicode UTF-8 and iso-8859-2 for their csv files. Is it possible to detect whether it is for...
This is probably a basic question for some, but it affects how I design a piece of my program.
I have a single collection of type A:
IEnumerable<A> myCollection;
I am filtering my collection on 2 different criteria:
IEnumerable<A> subCollection1 = myCollection.Where(x => x.Count > 10);
etc.
Now, I know that the .Where expression w...
I have a c# winform app that shows trading info to users. What we want to do is be able to open an excel sheet and have it request the data from the application. In return application gives data back to excel. After that if the data is updated in application, it also gets reflected in excel. In other words, we make excel display what app...
In Exchange 2007 this line of code is used to load the Exchange Poweshell commands snapin:
PSSnapInInfo info = rsConfig.AddPSSnapIn(
"Microsoft.Exchange.Management.PowerShell.Admin",
out snapInException);
However, this does not exist in Exchange 2010 and I am pulling my hair out trying to find out how to access the Exchange Powers...
I have a Silverlight Class Library that I want to use in both my Silverlight and my WebService project.
I am able to create and reference the Library in both projects without any problems, but when I try to use any of the classes in the Library on the Silerlight project, I get an ambiguous reference error between my Library and the Asm...
Basically I have a main form which upon loading, opens a child form for logging in the user. When they cancel or close this login form, I need to close the whole application.
But there seems to be a few different ways to close a C# program:
Application.Exit();
Application.ExitThread();
Environment.Exit(1);
Process.GetCurrentProcess()....
I'm working with some code that generates ICriteria queries for NHibernate. They get executed using ActiveRecord and ActiveRecordMediator.FindAll()
For certain queries, I need to optimise them by adding on an OPTION (HASH JOIN) hint at the end of the SELECT statement. Is there a quick way I can do this?
I don't want to rewrite the qu...
In C#, the LinkedList(T) class does not implement the IList(T) interface. However, the List(T) class does implement IList(T). Why is there this discrepancy? Functionally, they are both lists, so this design choice seems odd. It now becomes difficult to switch implementations from List(T) to LinkedList(T).
...
My .NET CF 3.5 application receives an Out of memory exception when DOM processing an xml file of size 2MB. Now I understand that this should be changed to SAX processing, but I was wondering why this error is received.
From http://blogs.msdn.com/b/mikezintel/archive/2004/12/08/278153.aspx,
"Windows CE creates one additional virtual ad...
I've created the following attribute:
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class OperationPermissionAttribute : CodeAccessSecurityAttribute
{
private static PrincipalPermission _revoke = new PrincipalPermission(PermissionState.None);
priv...
I have an API that returns XElement-s, and I want the document behind those XElement-s to be immutable (read-only). I need it for:
1) Not to give devs an ability to change it accidentally :)
2) Improving performance - creating a copy of an XDocument might be a performance "heavy" operation in some cases.
It doesn't seem to possible to ...
I have namespace with enums:
namespace Search
{
enum SearchConditionType
{
Like = 0,
EqualNotString = 1,
EqualString = 2
};
}
Then I try to declare enum:
namespace Search
{
public partial class Controls_SelectYesNo : System.Web.UI.UserControl
{
public SearchConditionType Field;
...
In context of recent trends in interviews i have noticed that this question arises every time. But when one answers the general definition then the interviewer says everyone knows it... tell something different. Further scenarios are asked where which one will be used and be beneficial and why
So kindly share any new insight into this t...
In the fragment below, the CodeBase property fails on the assembly System.Xml.Xsl.CompiledQuery, no where else. The message says that "The invoked member is not supported in a dynamic assembly".
I get that the CodeBase property is not implemented, what I don't get is why all of a sudden this is a problem. This code has been in service...
Hello,
following background: i have a Table-valued Function that returns a Table that is a kind of filtered view(views can not be parameterised) on a large table. Now i need many row count values on different conditions. Is it possible to get all count values in one query without having to query this function for every condition?
For th...
I know the foreach loop in the parallel class will "only need to do any expensive cross-thread access when it really needs to." But I like to keep a logger richtextbox that keeps track of all of the different steps as they complete. Is there a way to force the parallel foreach loop to update the control?
public void log(String msg...
I'm trying to dynamically build a LINQ query for LINQ to Entities so that I can avoid repeating the same function twice.
Here is what I'm trying to do:
private IUser GetOrUpdateUser(Predicate<IUser> filter, Func<IIdentityProvider, UserRecord> fetch)
{
var user = (from u in this.adapter.Users
where filter(u)
...
Here is my jQuery code:
function onSaveClicked()
{
var message =
{
MessageID: $("#MessageID").val() || 0,
MessageDate: "\/Date(<%= DateTime.Now.Ticks %>)\/",
};
$.ajax({
url: "<%= Url.Action("SaveMessage") %>",
type: "POST",
dataType: "json",
data: $.toJSON(message),
...
I had a discussion recently about looking for a mehtod to generate truly random numbers. The discussion ended up talking about using atmospheric noise. Has anyone done this? What is involved in the process? Has anyone created a web service that returns random numbers obtained from noise?
...
Hi,
I'm using Jon Skeet's (excellent) port of Google's Protocol Buffers to C#/.Net.
For practice, I have written a dummy Instant Messenger app that sends some messages down a socket. I have a message definition as follows:-
message InstantMessage {
required string Message = 1;
required int64 TimeStampTicks = 2;
}
When the send...