|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I more concern.
I want the metafile to be created in memory rather than saving to a disk. It should be a blank metafile. I assume it is like this.
metfile = New Metafile(hdc, EmfType.EmfPlusDual)
|
|
|
|
|
Hi,
I have a web service which returns JSON string like this:
{
"valid": true,
"messages": [
"Cannot validate bank code length. No information available.",
"Cannot get BIC. No information available."
],
"iban": "BH00000000000000000000",
"bankData": {
"bankCode": "",
"name": ""
},
"checkResults": {
"bankCode": false
}
}
I am able to get it using below code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://openiban.com/validate/" + txtIBAN.Text.Trim());
try
{
WebResponse response = request.GetResponse();
using (Stream responseStream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
string strsb = reader.ReadToEnd();
}
}
catch (WebException ex)
{
WebResponse errorResponse = ex.Response;
using (Stream responseStream = errorResponse.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
String errorText = reader.ReadToEnd();
}
throw;
}
but I want to know can I now read the value valid if it's rue or false?
Thanks,
Jassim[^]
Technology News @ www.JassimRahma.com
|
|
|
|
|
Use Json.NET[^] - you can add a reference via NuGet[^]:
Install-Package Newtonsoft.Json
You can then either use LINQ to JSON[^] to read the property:
JObject result = JObject.Parse(strsb);
bool isValid = (bool)result["valid"];
or create strongly typed classes to represent the result:
public class ResponseData
{
public bool valid { get; set; }
public IList<string> messages { get; set; }
public string iban { get; set; }
public BankData bankData { get; set; }
public IDictionary<string, bool> checkResults { get; set; }
}
public class BankData
{
public string bankCode { get; set; }
public string name { get; set; }
}
...
var result = JsonConvert.DeserializeObject<ResponseData>(strsb);
bool isValid = result.valid;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
To add to Richard's answer, you can use this free handy-dandy online tool to generate C# classes from JSON. You may want to rename the generated class names to be more developer friendly.
json2csharp - generate c# classes from json[^]
/ravi
|
|
|
|
|
|
When I look at the message text above, I think you can get confused by their convention. Their "valid": true seems to mean that the message you sent them was syntactically correct. But you are likely interested in the IBAN. And that's given in a different part of the message: "checkResults": { "bankCode": false } .
Well, I tried that service with my IBAN, and got following result (I edited the number on the response below):
{
"valid": true,
"messages": [],
"iban": "DE...........",
"bankData": {
"bankCode": "",
"name": ""
},
"checkResults": {}
} WTF... A valid IBAN is indicated by an empty checkresult and an empty messages array.
|
|
|
|
|
Respected sir /madam
good morning i want to send hindi sms from computer to mobile using asp.net c#.kindly send me hindi sms application code
thanks
|
|
|
|
|
No there is no Add to cart here...
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Hindi SMSes would be sent as a Unicode SMS (UCS2 encoding). If you have a basic SMS sending package, see 3GPP TS 23.038 (available for free at www.3gpp.org[^]) for the details that must be changed in the SMS fragment's header.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
modified 28-Jul-16 3:08am.
|
|
|
|
|
Is there a way to accomplish that a sequence of code does run exclusively, I mean no Task scheduling allowed while executing the sequence?
The reason behind it is, I try to determine the memory usage of a class this way:
private void MemoryTest()
{
const int cTestObjCount= 10000;
long before= GC.GetTotalMemory(false);
string[] stringArray= new string[cTestObjCount];
long after= GC.GetTotalMemory(false);
}
Or does somebody knows a better method how to determine the memory consumption of a class (without the help of a profiler)?
Thank you in advance.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
There is no way to prevent this in the .NET framework. Thread switching is in the control of the OS.
This space for rent
|
|
|
|
|
Thank you very much again for your help.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
The only reliable way would be to use a memory profiler. Either CLR Profiler[^] or PerfView[^] should do the job.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for this, I allready know it.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Error :The type or namespace name 'Contract_Kind' could not be found (are you missing a using directive or an assembly reference?)
///
/// Gathers values from contract kind checkboxes (Forex, Equity, Options)
///
private IEnumerable<contractkind> GetSelectedContractKinds()
{
if (chbFutures.Checked)
{
yield return Contract_Kind.Future;
yield return Contract_Kind.FutureCompound;
yield return Contract_Kind.GenericCompound;
}
if (chbForex.Checked)
{
yield return Contract_Kind.Forex;
}
}
}
Can somebody help me to fix this ERROR.
David
|
|
|
|
|
The error is fairly self-explanatory - you're trying to use a type called Contract_Kind which doesn't exist.
Either:
- you're missing a reference to the assembly where the type is defined; or
- you're missing a
using statement for the namespace where the type is defined; or - you've got the wrong type name; or
- you haven't written the type.
We can't see your code, so we can't tell you which of those options is the case.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have nested classes Inner class which is inherited by outer class. Inside inner class I have 2 integer properties. Which I use in Outer class to create 2 timer types.
Inner
Elapsed Time
Total Time
Outer class:
Inner inner1
Inner inner2
I use a loop to increment and update elapsed time property on inner1 of the outer class. The property updates, however the onproperty change event does not fire for the Outer class.
How do I bubble up the onproperty change event inorder to trigger the onproperty change event for my outer class.
|
|
|
|
|
This is usually done by creating a delegate and subscribing to the event. There is a tutorial on the subject at Delegates Tutorial (C#)[^].
|
|
|
|
|
rudedog1 wrote: have nested classes Inner class which is inherited by outer class. This does not make sense, please describe what your classes are, and which classes inherit from other classes.
Clarify whether you are talking about the outer class containing instances of the inner classes, or containing the actual definition of the inner classes.
Describe where and how you have implemented property notification change code.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
I have a class I define as inner class that contains 2 integer properties. This class is a nested class of a outer class which uses the inner class. The inner class is not a base class for the outer class. I am using these classes to create a type of timer. Timer has begin and end fields. I have created a singleton class that will read in information including beginning and end integer values. That will be used to populate the fields of the begin and end properties. The singleton class will increment through the begin and end range and update a textbox on a Form User interface. During the loop in the Singleton if triggers the onproperty change event of the property of the Inner class, however the onproperty change event of the outer class is not triggered. The onproperty change event of the outer class is the one needed to trigger the updates to the UI. I need to trigger the onproperty change event of the property of the outer class, when the onproperty change event of the inner class is triggered, to update my User Interface.
Class Inner
{
int begin;
int end;
public int Begin
{
get {return begin;}
set
{
begin = value;
OnPropertyChanged("Begin");
}
public int End
{
get {return end;}
set
{
End = value;
OnPropertyChanged("End");
}
}
}
Class Outer
{
Inner timer1;
Inner timer2;
public Inner Timer1
{
get {return timer1;}
set
{
timer1= value;
OnPropertyChanged("Timer1");
}
public Inner Timer2
{
get {return timer2;}
set
{
timer2= value;
OnPropertyChanged("Timer2");
}
}
|
|
|
|
|
I'd like to suggest you use the CP editor to format your code so it's more readable.
Also, I do not see your implementation of PropertyChanged notification. This is Windows Forms ... or WPF ?
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
When I create a new empty C# Windows Application project in Visual Studio a form shows up that I can drag and drop components from the toolbox onto and easily change their sizes, locations, default texts, etc. Is this "graphical" way of programming possible to do with a class that, for example, inherits a Panel, GroupBox or similar? How do I do that in that case?
|
|
|
|
|
Yes - if you create a UserControl then when you have next successfully built your project it will appear in the tool box at the top when you open your Form design view.
A UserControl is basically a blank Panel that is ready for you to add what controls and functionality you need to.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks. Is it possible to inherit a Panel, GroupBox, etc if I use this techninue? It's not super important that I inherit, but if possible I would like to do so.
|
|
|
|