|
Sorry, I have no idea, your question is far too general. You need to do some research to see what features are available with whatever software you plan to use.
|
|
|
|
|
okay....
sir i want to add text box, all shapes ,in panel like select and drop onto panel and this are stretchable and this panel size set by me for printing size as ID Card can i set this??? pls help me
thank you
|
|
|
|
|
Member 13123466 wrote: pls help me How? We have no idea what your program is doing or where you have a problem. If you do not understand the basics of laying out controls on a form then you should go to the Articles section and do some research.
|
|
|
|
|
Is there a way to re-direct the output of a ?wsdl to a listbox?
for example, I'd like to add a button that invokes the following:
http://serverName:port/service.svc?wsdl
and send the output to a listbox
many thanX
|
|
|
|
|
Yes, you would need to parse the response into whatever separate items you want, and then add each one to the listbox.
|
|
|
|
|
Hi,
I need to create a program to ask the user about 20 integers and find the highest number using for-loops and arrays. The code I've created is not working since it's not giving me the highest number. Can someone please advise me on what to do/change?
//======MY CODE======
int[] tal = new int[20];
for (int i = 0; i < 20; i++)
{
Console.WriteLine("Skriv ett nummer: ");
string strNr = Console.ReadLine();
int nr = Convert.ToInt32(strNr);
tal[i] = nr;
}
int largest = 0;
for (int i = 0; i < tal.Length -1; i++)
{
if (i > largest)
largest = i;
}
Console.WriteLine("Det största talet är: ", largest);
Console.ReadKey();
|
|
|
|
|
The code is finding the highest index up to tal.Length -1 . Both of those things are the wrong thing to do.
|
|
|
|
|
Your loop is not counting to the end, and is comparing the wrong item. It should be:
for (int i = 0; i < tal.Length; i++)
{
if (tal[i] > largest)
largest = tal[i];
}
|
|
|
|
|
So I'm working on scavenging data from a vendor supplied product that uses an Access DB as its method of data storage. Since it's Access and they know it's not really an efficient database, they do all kinds of weird things in handling their data. They delete anything over 3 days old and they don't use the ID field as you would expect. So what I'm looking to do is pull new values once a minute or so based upon the timestamp. The problem comes in with Daylight Savings and the time changes. So to work around this, I'm thinking of converting to UTC to do the comparison using one of these two methods:
DateTime.ToUniversalTime Method (System)[^]
TimeZoneInfo.ConvertTimeToUtc Method (DateTime, TimeZoneInfo) (System)[^]
I'm worried that I'm going the overkill route though. Anyone have any thoughts?
modified 15-May-17 13:13pm.
|
|
|
|
|
How are the dates stored in the database? NB: they should be stored as DateTime types, i.e. UTC.
|
|
|
|
|
It's Access. So I'm assuming the worst.
|
|
|
|
|
My first thought would be: what time zone is used when the data is inserted or updated in the database?
If it's the local time zone on the computer that's running the application, then you might struggle. There's no guarantee that they're all set to use the same time zone, or that their clocks are properly synchronized. And once the value is in the Access database, you've lost all time zone information.
If all the computers are in a domain - and all in the same time zone - you might be able to use Group Policy to manage the time zone:
windows - Setting time zones with site-based Group Policy - Super User[^]
Domain-joined computers will probably be set to synchronize their clocks with the domain controller, so you should be OK.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Luckily the application and the data will be on the same computer. I think that by using the second method, which is able to get the local timezone info and convert it to UTC, I'll be able to avoid that mess.
|
|
|
|
|
Hi,
When I try the following code, I receive an error which says:
Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Test.Program+NewsItem]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'data', line 2, position 8.'
On this line:
List<NewsItem> items = JsonConvert.DeserializeObject<List<NewsItem>>(json);
Here is my Code:
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization;
namespace Test
{
public class Program
{
public class News
{
public IList<NewsItem> data { get; set; }
}
public class NewsItem
{
public IList<string> title { get; set; }
public IList<string> body { get; set; }
}
public static void Main(string[] args)
{
string json = "";
using (StreamReader r = new StreamReader("data3.json"))
{
json = r.ReadToEnd();
List<NewsItem> items = JsonConvert.DeserializeObject<List<NewsItem>>(json);
}
List <News> allNews = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<List<News>>(json);
foreach (var item in allNews)
{
foreach (var record in item.data)
{
Console.WriteLine(record.title);
Console.WriteLine(record.body);
}
Console.ReadLine();
}
}
}
}
And here is my JSON sample object:
{
"data": [{
"body": ["<p>part 1-1</p>", "<p>part 1-2</p>"],
"link": "http://www.test.com",
"title": ["sample title 1"]
},
{
"body": ["<p>part 2-1</p>", "<p>part 2-2</p>"],
"link": "http://www.test.com",
"title": ["sample title 2"]
}
]
}
Thank you in advance for your time and consideration.
|
|
|
|
|
Your data tag in the JSON is not an array yet your C# code it treating it as one.
|
|
|
|
|
Your NewsItem class is missing a definition of the link JSON entry.
|
|
|
|
|
JSON.NET, and most other JSON libraries, will simply ignore any missing properties.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, something I need to test. However, looking at the question again, shouldn't it be trying to deserialise int a News class, rather than NewsItem?
|
|
|
|
|
Richard MacCutchan wrote: shouldn't it be trying to deserialise int a News class, rather than NewsItem?
Indeed. As I posted below.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Farhad Eft wrote: JsonConvert.DeserializeObject<List<NewsItem>>(json);
Farhad Eft wrote: new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<List<News>>(json);
The JSON you've posted is neither a List<NewsItem> nor a List<News> ; it is simply a single News object.
string json = File.ReadAllText("data3.json");
News allNews = JsonConvert.DeserializeObject<News>(json);
foreach (NewsItem item in allNews.data)
{
foreach (string title in item.title)
{
Console.WriteLine(title);
}
foreach (string body in item.body)
{
Console.WriteLine(body);
}
Console.WriteLine();
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You guys are simply amazing!!
Thank you!
|
|
|
|
|
Assuming I've defined a hierarchy of #whatever that allows nesting an arbitrary number of levels : then, I delete a reference to a top-level #whatever instance which contains #n levels deep of #n other #whatever instances:
Can I assume that the #whatever instance now-without-a-reference, and all its sub-levels of references/instances, will be garbage collected ?
Or, is it on me to recursively remove child references ? Of course, it is on me to handle references in the code to sub-elements that are "outside" the parent/ancestor inheritance chain.
Is there a specific 'Dispose technique that can be used here ?
Note: I've deliberately phrased the hypothetical here in an abstract way, to avoid talking about what a specific Control, like the WinForms TreeView, might implement internally.
thanks, Bill
«When I consider my brief span of life, swallowed up in an eternity before and after, the little space I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which know me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then.» Blaise Pascal
|
|
|
|
|
Hi Bill,
1. an object is dead and collectable as soon as you no longer have a reachable reference to it (reachables are inside other obects that are reachable, stacks, static variables, ...). When a number of objects have internal references to each other but no outside references are alive, then all of those objects are dead/collectable.
2. exactly when they get garbage collected is more complex, it depends on the size, the generation number, when your GC runs, etc. However one normally should not care about this, that is the GC's job.
3. when your objects have a Dispose() method (necessary when they may hold pointers to unmanaged system resources), then for each of them the Dispose() method will be called eventually by the GC. In this case it is advisable to call their Dispose() explicitly so the system resources get released ASAP.
Note: providing a Dispose() method will somewhat postpone the GC freeing their memory, so providing a Dispose() on huge objects is a bad idea!
4. when your Application terminates neither of those mechanisms will work for you; instead Windows itself will reclaim all memory and all system resources your program was using (unless...), so you can't safely implement wanted side effects in your Dispose() method as your program might terminate before Dispose() gets called by the GC!
Hope this helps and is sufficiently clear and accurate.
modified 15-May-17 5:43am.
|
|
|
|
|
Thanks, Luc, that is very clear, very helpful.
cheers, Bill
«When I consider my brief span of life, swallowed up in an eternity before and after, the little space I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which know me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then.» Blaise Pascal
|
|
|
|
|
Hi Luc
It seems you have mixed finalizers and IDisposable.Dispose() in your reply.
The garbage collector will never call Dispose. It will call the finalizer if one is present.
|
|
|
|