|
am developing an windows application where i am using MSI plessey TTF font in this font i need to calculate check digit so how can i do that check digit calaculation
|
|
|
|
|
private string msiplessey(string abc)
{
string value = "";
string values = "";
string adds = "";
string evenvalues = "";
string evenval = "";
string evenadds = "";
string resultadd = "";
string fval = "";
long add = 0;
long abcd;
long evenadd = 0;
long result;
int checkvalue = 0;
int finalresult;
for (int i = abc.Length - 1; i > -1; i -= 2)
{
value += abc.Substring(i, 1);
}
for (int j = value.Length - 1; j >= 0; j--)
{
values += value.Substring(j, 1);
}
abcd = (Convert.ToInt64(values) * 2);
string oddvalue = abcd.ToString();
for (int k = 0; k < oddvalue.Length; k++)
{
adds = oddvalue.Substring(k, 1);
add = add + Convert.ToInt64(adds);
}
for (int l = abc.Length - 2; l > -1; l -= 2)
{
evenvalues += abc.Substring(l, 1);
}
for (int m = evenvalues.Length - 1; m >= 0; m--)
{
evenval += evenvalues.Substring(m, 1);
}
for (int n = 0; n < evenval.Length; n++)
{
evenadds = evenval.Substring(n, 1);
evenadd = evenadd + Convert.ToInt64(evenadds);
}
result = add + evenadd;
resultadd = result.ToString();
finalresult = Convert.ToInt32(resultadd.Length);
fval = resultadd.Substring(finalresult - 1);
checkvalue = (10 - (Convert.ToInt32(fval)));
if (checkvalue == 10)
{
checkvalue = 0;
}
else
{
checkvalue = (10 - (Convert.ToInt32(fval)));
}
return checkvalue.ToString();
}
|
|
|
|
|
Hi there.
I think string and String class are equivalent.
Is it true ?
What are the different between them ?
modified on Tuesday, May 27, 2008 3:04 PM
|
|
|
|
|
M-Dayyan wrote: I think string and String class are equivalent.
Is it true ?
string is a synonym for System.String
|
|
|
|
|
|
Hi Colin,
Not on topic but you may know...
Consider the declarations below:
<br />
<br />
public Delegate void Testing1();<br />
public delegate void Testing();<br />
<br />
The first declaration will not compile. I thought delegate and System.Delegate were the same things?
Cheers,
|
|
|
|
|
No its not the same thing..
"Delegate" is the baseclass that all delegates derive from.
(containing methods like DynamicInvoke etc)
The "delegate" keyword will tell the compiler that it should output a class deriving from Delegate.
(delegates are classes in IL)
So "Delegate" is more like object/Object.
While "delegate" is like the "class" keyword.
eg:
public class SomeClass : Object
public delegate void SomeDelegate () /* : Delegate */
|
|
|
|
|
Java's Properties class (http://java.sun.com/javase/6/docs/api/java/util/Properties.html[^]) is an easy way to serialize a bunch of properties to and from a file. I am trying to port a Java application that makes heavy use of this class, to C#. What is the easiest way to emulate this behavior?
I thought about XML serialization, but that doesn't work because all the field names have to be specified in advance. Any ideas?
|
|
|
|
|
How about a Hashtable. The Java properties class extends Java's implementation of a hashtable, so why not use a Hashtable in C# also?
|
|
|
|
|
Hey Colin,
That's true, it does extend hashtable - but the real value of the Properties class comes in the utilities it provides for saving/loading that hashtable's contents to streams in different formats (XML, flat file, etc.) This capability is what I am looking for. If I don't find it I'll have to write it and post it here
|
|
|
|
|
using application/ user settings in c# is at least as easy as properties in java. however, c# settings are serialized in xml, whereas properties are not.
|
|
|
|
|
I have a predefined user control designed at design time, and want it to load a form at runtime
it seems simple but i can't get it to work
pls help
|
|
|
|
|
Don't you just make an instance of the control and the add it to the form, like so:
MyCtrl control = new MyCtrl();
control.ClientSize = new Size(100,25);
control.Location = new Point(3,3);
...
myMainForm.Controls.Add(control);
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Yes thanks!!!
I used the same way but made an error in the namespace
|
|
|
|
|
I put a binary file into a table in a dataset. I then write my dataset as a XMLfile using DataSet.WriteXML
When I look at the field with my file-content I have a string wich look like this ...
"<content>/9j/4AAQSkZJRgABAgEAYABgAAD/7ABzRHVja3kAAQAEAAAAPAADAF4AAAAtA<"
What kind of string is that? How can I get it without using dataset/writexml to get it?
I have a special solution where I need to get that string.
Please hekp // henrik
|
|
|
|
|
How are you storing your binary file before putting in the datatable? If you store binary file in byte[] then Google for 'convert byte array to string' You can use BinaryReader class for reading binary data.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I think the DataSet uses Base64 encoding when it serializes binary fields into XML. I may be wrong, but it is the most common way to encode binary data in XML.
To read it, you could use a System.Xml.XmlReader (and its ReadElementContentAsBase64 method once you've located the correct field). However, the normal way to do it would be to recreate the dataset from the XML file, though (using ReadXml on a new dataset)...
If for some reason you don't want to use the system-provided XML tools and instead want to read the file as text and do your own decoding, you can either google for base64 or use, for example, System.Convert.FromBase64String.
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
Yeap ... It is base64 ...
Found the solution yesterday ...
Thanks // HenrikDaSwede
|
|
|
|
|
MaWeRic wrote: Thanks // HenrikDaSwede
We are the turnips[^]. You will be assimilated. Resistance is futile...
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
The app I'm working on has quite a lot of collections, some of which will hold several thousand items that have numerous fields - some of which are collections themselves.
At the moment I'm leaving everything to GC automatically and it's working, but I'm concerned that it may cause problems in production on lower spec machines if GC doesn't reclaim the memory.
Would I be better implementing IDisposable? Are there any pitfalls to doing so?
Dave
|
|
|
|
|
Since you don't have code that access unmanaged memory, no need of implementing a dispose pattern. GC is efficient and it will take care AFAIK.
|
|
|
|
|
Well...that's only partially true. If any of the objects in the collection implement IDisposable then he should also implement IDisposable so that those objects can get cleaned up when the collection goes out of scope or gets collected.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
You are correct scott. Thanks for pointing it out.
|
|
|
|
|
The short and simple answer is: "Probably, yes." However, you haven't really provided a lot of details.
A couple of questions to think about:
1. Do any of the objects that will be contained in the collections implement IDisposable?
2. How large are the objects that will be contained in the collections?
If any of the collection items implement IDisposable, then yes, you definately should implement IDisposable so your collection can call Dispose on the items.
If your items are large (greater than about 85,000 bytes) you should probably still implement IDisposable, but definately make sure you set the items to null.
You can take a look at this article[^] for more information on IDisposable in general.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Thanks Scott.
None of the objects implement IDisposable directly but use methods that use objects that do - although these are all in using blocks.
Most of the items will be greater than 85K so I'll implement it.
Article bookmarked for investigation!
Dave
|
|
|
|