I have a statement where a string is assigned in the following manner:
for(int i = 0; i < x; i++) {
Foo.MyStringProperty = "Bar_" + i.ToString();
[...]
}
Are there any performance differences between i.ToString() or just plain i, as both are just converted to the (culture invariant?) string equivalent?
nb. I am well aware of the ...
I am extracting a bool value from a (non-generic, hetrogeneous) collection.
The as operator may only be used with reference types, so it is not possible to do use as to try a safe-cast to bool:
// This does not work: "The as operator must be used with a reference type ('bool' is a value type)"
object rawValue = map.GetValue(key);
bool ...
I have two questions:
I'm wondering how I can display no link text when using Html.ActionLink() in an MVC view (actually, this is Site.Master).
There is not an overloaded version that does not allow link text, and when I try passing in just a blank string, the compiler tells me it needs a non-empty string.
How can I fix this?
I ...
Hello,
I have a listener that returns a TcpClient that must read data until the other side closes or until we stop.
I have created a simple Form with two buttons. One starts one connection and the other stops it.
The problem is that when I have a IOException due to the timeout of the Read the socket is closed and I cannot communicate...
<name>Hello '"world", ü ë &%;</name>
<label>''MHU233%;'</label>
XmlSerializer.Deserialize(XmlReader) throws an InvalidOperationException in first case above. Would like to know what is wrong and why latter is ok. XmlReader is created with XmlSettings in constructor where Xml-schema is in SchemaSet.
Thanks!
...
What's the best way to manipulate URIs in .NET compact framework? I basically need to load up a URL string, then allow the user to change the "Scheme" and "Host" values. I've been using the Uri class so far, but it's essentially immutable, so you can't really modify any of the components of the Uri, once it's initialized.
The UriBuild...
I'm trying to create and use a .NET StreamWriter object inside a classic ASP page (VBScript). Normally I would create the object like this:
Dim writer
Set writer = Server.CreateObject("System.IO.StreamWriter")
However, the constructor for StreamWriter takes a Stream object as a parameter, and the call to CreateObject fails. Even if I...
I have been pulling my hair out trying to solve this. What I am attempting to do is to build a 'map' of how objects are being used in a bit of code I am working on. Think of it as an enhanced Find Usages. The easiest way to show this is by example:
public class MasterClass
{
Type1 type1;
Type2 type2;
Type3 type3;
void In...
I have a 2 Entity : Person (Id, CategoryId) and Category(Id).
Now when I try to insert a new Person with only the Id and CategoryId it throws an exception about the Person having a relationship with Category.
The following code doesn't work:
Person newPerson = new Person();
newPerson.Id = 1;
newPerson.CategoryId = 1;
context.AddToPer...
what c# ftp client do you guys recommend? there seems to be a few available and I want to go with one that others think is good
...
I am working on a .NET project, which needs to interact with some user defined classes - reffered to as "jobs". All job classes must implement a specific interface IJob in order order for the library to consume them. Sometimes a job class might hold unmanaged resource, which needs to be explicitly disposed.
How should I ensure that all ...
I am trying to set up Cruise Control so that it runs as a service. How is this done? Also what difficulties as far as rights go might I run into?
...
Hi All,
I'm relatively newbie to ASP.NET, and just building my second realtime webapplication.
When I was learning ASP.NET a year back, I have been told "It is costlier to connect and grab data from database, so make as much less connection as possible and re-use the retrieved data effectively". The reasons given are
A connection t...
Hello,
I'm have an issue with this entity query that I am hoping to get some help with.
Overall what I am trying to do is query for entries in the GoalNotes table as well as include the Employee reference for each note. The GoalNotes table has a foreign key relating it to the Employee table.
I am then trying to query the GoalNotes tab...
Okay here is a softball beginner WPF question.
By default the background of the window is white. I'm trying to hack in an error reporting form and I want to emulate the more standard windows look and feel.
Any easy way to grab the default color for the background?
...
I am new to design patterns, but I have been trying hard to implement some in the last year. I started at a new organization, and all the code was contained in the form. Since I got here, I've been trying to use an MVC approach for our .NET 2.0 application.
Other developers have started to see the need for this approach, and we are ...
I'm relatively new to C# and .NET and I'm trying to learn how to better handle exceptions in my code.
Take the following function I've written for example:
public void SendEmail(string SenderEmail, string SenderDisplayName, IEnumerable<string> RecipientEmails, string Subject, string Message)
{
MailMessage message = new Ma...
So I am trying to make a program where the user is limited in moving the mouse to a form. I still want the user to see whats going on behind the form but not be able to click on anything but my form.
I tried using this
Cursor.Clip = Me.RectangleToScreen(Me.ClientRectangle)
The problem is that if the user clicks in certain spots on ...
i need to add checkboxes to every cell in the calendar so that the user can select multiple dates and the dates get stored in the database for later retrieval.
basically i am developing a calendar as a signup sheet for day shift and night shift. so i need 2 checkboxes per calendar date in the calendar. is it possible. i am using Visual s...
I created a sqlconnection, CN1. Then this CN1 is opened. Later in the code there is a transactionscope. If I execute a sql command on this CN1 connection, is this within transaction?
Code looks like this;
SqlConnection cn1 = new SqlConnection();
cn1.Open(); //connection opened when there is no ambient transaction.
...
using(Transactio...