|
My code actually has a catch for my try. I just didn't include it here to simplify.
So it works for you basically as-is?
|
|
|
|
|
It is working. Given what you have said, the problem could well be in the catch . You need to step through your code to determine what is happening exactly, unless someone here come up with a full solution.
|
|
|
|
|
Ok. I figured it out. I was constructing one of my strings wrong and wound up with one that was 282, so it was throwing an exception when it tried to convert to byte and never got to copying the temp array to my final Dat array.
|
|
|
|
|
|
Lesson learnt: Never write an empty catch block.
|
|
|
|
|
void GetNameChangedToProtectTheInnocent()
{
try
{
...
}
catch
{
}
}
There you go - not empty! Written by yours truly, only 10mins ago . In my defence, it's important that the site doesn't throw errors and this is what the rest of the site does.
|
|
|
|
|
Fair enough, but it should at least be logged for investigation. If it's unimportant and not worth logging then it should be handled in code so the exception never arises.
|
|
|
|
|
I was being a bit (OK, very) toungue-in-cheek. 99.99% of the time I really wouldn't do this. In this case he exception is very unimportant, for various reasons I'd have to write my own logging infrastructure (which would take longer than the rest of the change, and my code is slated for replacement by an MVC app very soon) and I can't handle in code as the try-block is calling out to an asmx service and I'm guarding against technical errors. I could, I suppose tighten which errors are being caught.
|
|
|
|
|
Actually, my catch block had a lot in it. It was just not included in my post!
|
|
|
|
|
In Visual Studio, You can enable breaking at an exception even when it is caught and handled. This will be very useful during debugging.
|
|
|
|
|
I wonder if it's my data. My strings are "00", "55", "20", "00", and "99".
|
|
|
|
|
plz i need link of proggrams in c# concern with panorama images (stitching image)
help me
|
|
|
|
|
Please read the top message on this board ("How to ask a question") otherwise people will down-vote your question. Asking for code like this is unlikely to get a response as we are pretty much all volunteers here. Everyone will assume you have tried nothing even if, in reality, you have spent hours figuring it out - we can't tell. Stitching photos isn't a facile task, and unlikely to be answered in a forum post.
It is better to ask a specific question, outlining what you have tried to achieve, or, what the exact problem is you are having getting started. Oh and a title of "hello isn't very descriptive"
|
|
|
|
|
|
See this[^] excellent article that uses the Accord and AForge frameworks.
/ravi
|
|
|
|
|
Hi,
I want to know how to store data in excel using VC# 2010.
i.e.) i will enter the values in UI say name and age, and i want those values to reflect in my Excel sheet without using any database.
Can anyone please share me the code for this.
|
|
|
|
|
Anusha Sridhar wrote: Can anyone please share me the code for this.
You are asking if anyone can write the code for you. Create a UI, do a quick Google, try something (any tutorial or example will do) and report back if you're stuck.
Alternatively, you could cough up a nice amount for WarChild, and I might be tempted to copy/paste one of the tutorials from Google here.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Use Office Open Xml SDK to achieve this.
Refer this thread. Create a DataTable object from your UI code and use the rest of the code in the solution.
|
|
|
|
|
I use ADO.net with the OleDb provider for Jet/Ace
See also: http://connectionstrings.com/excel[^]
and then it's simple SQL:
create table Test (ID number,Name string)
insert into Test VALUES ('1','Alice')
insert into Test VALUES ('2','Bob')
SELECT * FROM Test
Etc.
|
|
|
|
|
Hello all,
I'm trying to download a file from a folder on the server but I don't know how to parse the path inside of the HREF attribute of the anchor tage. I'm trying to modify the following code to be used with HTML anchor tag:
protected void Page_PreRender(object sender, EventArgs e)
{
DataTable dt = new DataTable("INFO");
dt.Columns.Add("url", typeof(string));
string[] fileEntries = Directory.GetFiles(Server.MapPath("~/Documents/"));
dt.Rows.Add("~/Documents/" + Path.GetFileName(fileName));
grid.DataSource = dt;
grid.DataBind();
}
I wanted to do something like the following on my Page.aspx file:
<a href="~/Documents/" + Path.GetFileName(fileName)"> DOWNLOAD </a>
However, the above cannot be done. Please help me find and alternative, thanks for your help.
|
|
|
|
|
Could you please ask questions about ASP.NET in the ASP.NET forum. That's where you will find ASP.NET experts.
|
|
|
|
|
Hi, this thread represents a summary of what I have learned since starting the thread [^] on this forum: re use of dynamic to allow direct access to a 'value without the need for casting that 'value (currently an 'object) to its appropriate type.
In the code below I compare and contrast for three different types of .NET types, KeyValuePairs, Tuples, and List<dynamic> what using 'dynamic enables compared to using 'object in the constructor of these types.
I am particularly interested in the reactions of Martijn Kok and DaveyM69, who were kind enough to post interesting comments on the original thread: I believe, that what I demonstrate here does change the implications of one comment by Martijn Kok (as I understood that comment: and my understanding may well be in error).
Of course, comments would be welcome about use of 'dynamic in general, and the potential "overhead" of using a Type like List<dynamic> !
I would also be interested in knowing your opinion if there is enough material here for a "Tip/Trick."
thanks, Bill
// KeyValuePair declarations
private KeyValuePair<Type, object> Kvp1 = new KeyValuePair<Type, object> (typeof(int), 199);
private KeyValuePair<Type, dynamic> Kvp2 = new KeyValuePair<Type, dynamic>(typeof(int), 199);
// Tuple declarations
private Tuple<Type, object> twoTuple1 = new Tuple<Type, object>(typeof(int), 199);
private Tuple<Type, dynamic> twoTuple2 = new Tuple<Type, dynamic>(typeof(int), 199);
// List<dynamic> declaration
private List<dynamic> dyList = new List<dynamic>();
// method that demonstrates use of declared objects above
private void TestDynamicVsNonDynamic()
{
// using KeyValuePair
//int a = Kvp1.Value + 1; // will not compile
int b = Kvp2.Value + 1; // will compile, give expected result
// using Tuple
//int x = twoTuple1.Item2 + 1; // will not compile
int y = twoTuple2.Item2 + 1; // will compile, give expected result
// using List<dynamic>
dyList.Add(199); // will compile
dyList.Add(new TextBox{Text = "some text&"});
int z = dyList[0] + 1; // will compile, give expected result
dyList[1].Text += " ... blah, blah blah";
string s = dyList[1].Text; // will compile, give expected result
Type dyList1Type = dyList[1].GetType(); // returns expected Type: TextBox
}
"If you shoot at mimes, should you use a silencer ?" Stephen Wright
|
|
|
|
|
Hi Bill,
The results you show are exactly what I would expect. Using object , although the Type is readily available, to use it as that type (using the + operator in your example) requires a cast:
int a = ((int)(Kvp1.Value)) + 1;
dynamic does not have this limitation as Kvp1.Value in your example will be dynamically resolved to an int at runtime and therefore has all the functionality of that struct.
This is the primary (only?) advantage of dynamic over object - using object can require casts all over the place! What the overhead is of dynamic (if any) I don't know as I've never found the need to use it in my own code.
|
|
|
|
|
Thanks, DaveyM,
What I remain puzzled by is that if I use, for example, a KeyValuePair<Type,object>: like this:
private KeyValuePair<Type, object> kvpTO;
private void messWith_kvpTO()
{
kvpTO = new KeyValuePair<Type, object>(typeof(string), "some text");
Type workingType = kvpTO.Key;
// workingType now contains:
// [System.RuntimeType] = {Name = "String" FullName = "System.String"}
// fail "cannot recognize kvpTO"
//string kvpString = (workingType) kvpTO.Value;
// fail "cannot recognize kvpTO"
//string kvpString = kvpTO.Value as workingType;
} I cannot find any way to use the valid run-time Type to convert the "string" from an object to a string in a generic way: where the Type could any valid Type, and I do not know what that Type is at run-time.
Have any idea how to do that ?
It was my inability to use the 'Type in the 'KeyValuePair to do "casting" from object: that led me to using 'dynamic.
best, Bill
"If you shoot at mimes, should you use a silencer ?" Stephen Wright
|
|
|
|
|
As you're storing the Type and the object in one pair so it's guaranteed to be a valid cast, you could use Convert.ChangeType[^] to do this:
string kvpString = Convert.ChangeType(kvpTO.Value, kvpTO.Key);
|
|
|
|