|
Dear
I have futronic fs80 fingerprint scanner and I want to integrate with c# so I searched online but I didn't find any sample code or tutorial how to integrate it with c# also on
futronic website but it didnt give me any obvious way so I need your help?
|
|
|
|
|
Contact the manufacturers; they are most likely to have an SDK that goes with the device. If they don't then demand your money back.
|
|
|
|
|
i have tried array bytes data convert to json format
|
|
|
|
|
Does this have anything to do with C#?
|
|
|
|
|
You can't just send a byte array through JSON; you would need to serialize it first with something like:
System.Text.Encoding.UTF8.GetString(byteArray);
But on the other side you would need a mechanism to convert from a UTF-8 string into a byte array.
You can also send it via BSON NuGet Gallery | Newtonsoft.Json.Bson 1.0.1 with the same caveat, but there is a JS library built for that by MongoDB at GitHub - mongodb/js-bson: BSON Parser for node and browser.
If none of that will work for you, you will need to sent the file raw with the proper headers for the file type.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I have researched multiple sources and have come up with the following code that sorts the input array from low to high and outputs the sort order of position in the new sorted array.
The code below works, but I'd like to further optimize the final 11 x While loops into something that is more efficient. What is the best way to optimize this code?
Your help is greatly appreciated!
int[] i = {9, 2, 7, 6, 1, 3, 5, 4, 8};
int[] j = (int[])i.Clone();
int P01 = 0;
int P02 = 0;
int P03 = 0;
int P04 = 0;
int P05 = 0;
int P06 = 0;
int P07 = 0;
int P08 = 0;
int P09 = 0;
int va = 0;
int vp = 0;
bool swapped = true;
while (swapped) {
swapped=false;
va = 0;
while (va < i.Length -1)
{
if (i[va] > i[va+1]) {
int swap = i[va];
i[va] = i[va+1];
i[va+1] = swap;
swapped=true;
}
va++;
}
}
vp = 0;
while (vp < j.Length -1)
{
if (j[0] = i[vp]) {
P01 := vp + 1;
}
vp++;
}
vp = 0;
while (vp < j.Length -1)
{
if (j[1] = i[vp]) {
P02 := vp + 1;
}
vp++;
}
vp = 0;
while (vp < j.Length -1)
{
if (j[2] = i[vp]) {
P03 := vp + 1;
}
vp++;
}
vp = 0;
while (vp < j.Length -1)
{
if (j[3] = i[vp]) {
P04 := vp + 1;
}
vp++;
}
|
|
|
|
|
The logic of your code looks like a valid bubble-sort, but your code is not C#, and this is the C# forum. Sorting in computer science is a vast topic with many algorithms that have been extensively studied, compared; I think writing your own code for bubble-sort and quicksort is a good assignment for entry-level students.
A good review of basic sorting techniques, with code examples, in C#: [^] : look how simple their bubble-sort example is:
public static void IntArrayBubbleSort (int[] data)
{
int i, j;
int N = data.Length;
for (j=N-1; j>0; j--) {
for (i=0; i<j; i++) {
if (data [i] > data [i + 1])
exchange (data, i, i + 1);
}
}
}
public static void exchange(int[] data, int m, int n)
{
int temporary;
temporary = data[m];
data[m] = data[n];
data[n] = temporary;
}
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Hi,
what you wrote (at least the first loop) is a bubble-sort, which is quite inefficient for large arrays. There are other algorithms that basically use fewer comparison operations.
As for positions, you could merge all the remaining loops into one or two. Have a look at Dictionary<int,int>. You need to be careful when the array is allowed to contain duplicate values! Of course your positions should be stored in an array or some collection to support variable lengths.
There is a fundamental alternative, which does not modify the data array, instead it works on an index array, which holds positions, so initially it contains 0,1,2,...n-1 and finally it holds all the final positions. This in general is not the fastest approach, but it is pretty simple.
You don't have to write your own sorting code, how about:
int[] i = {...};
int[] j = (int[])i.Clone();
Array.Sort(j);
Advanced stuff: the Array.Sort() method allows you to specify a comparison method, which is useful when a special order is required, or when the array contains objects rather than numbers.
And if you allow for specialized solutions then the ultimate is:
int[] i = {9, 2, 7, 6, 1, 3, 5, 4, 8};
int[] j = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
|
|
|
|
What say you, my esteemed mentors and peers ? This is non-news; bad news; worth writing up as tip-trick ?
Use a nullable of that same generic parameter as a return value: I was aware there was some behind the scenes compiler magic with a hidden 'HasValue flag in a nullable 'struct that allowed an instance to be assigned null, but I never thought I could use the non-nullable generic parameter in the way shown here:
public static class ConversionExtensions
{
public enum ConversionType
{
SByte, Byte, Int16, Int32, Int64,
UInt32, UInt64, Single, Double,
Guid
}
static Dictionary<Type, TypeConverter> TypeToConverter = null;
public static T? TryParse<T>(this string str) where T : struct
{
if (TypeToConverter == null)
{
TypeToConverter = new Dictionary<Type, TypeConverter>();
foreach (string ct in Enum.GetNames(typeof(ConversionType)))
{
var t = Type.GetType("System." + ct);
TypeToConverter.Add(t, TypeDescriptor.GetConverter(t));
}
}
Type type = typeof(T);
if (TypeToConverter.TryGetValue(type, out TypeConverter tc))
{
try
{
return (T) tc.ConvertFromString(str);
}
catch
{
return null;
}
}
else
{
throw new KeyNotFoundException($"this converter does not handle Type: {type.FullName}");
}
return null;
}
}
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
modified 10-Jun-18 12:33pm.
|
|
|
|
|
I think it's clever, but I can't say that I'm thrilled that this is possible. If I were using a library and got a "possible null reference exception" from a value type, I'd likely waste a fair amount of time trying to figure out what was going wrong.
I'm generally not a fan of blurring the lines between values and references.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Thanks for your thoughts, Nathan !
I'm not advocating this as the "best way:" I can see a valid argument foe using an out parameter, and returning a bool ... building on the 'TryParse syntax we are used to. I think I'll add the code for that technique to the post, and perhaps, get some more reactions.
By the way: in practice, I'm fanatic about controlling numeric entry in TextBoxes by using Key Event handlers to screen out unacceptable key entries, so this experiment is just a challenge I took on to get familiar with the 'TypeConverter facility.
The use of the currently shown code looks like this:
var v0 = tBxNumericUC1.Text.TryParse1<int>();
if (v0 != null)
{
} The usage of the code that's more like 'TryParse would look like:
if (tBxNumericUC1.Text.TryParse<int>(out int iresult)
{
}
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
modified 11-Jun-18 14:15pm.
|
|
|
|
|
I have a couple of custom MVC implementations that act similarly. I'm working on one of those projects now, and I must confess that I forgot how hard it can be to troubleshoot.
Also: pretty much every other line is a null check. I sort of hate that
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
|
Google translate: "I posted this in the appropriate place, but I didn't get a quick enough reply so I thought I'd drop hints everywhere else".
They are getting clever these days, Google...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Your original post was in the correct forum.
Spamming other forums with "please look at my post" messages just because you didn't get an answer quickly enough is, at best, annoying.
Remember, the people answering questions here are volunteers. Nobody is under any obligation to answer your question at all, let alone within a particular time-frame.
Also, members are spread out across the globe, and may not have had a chance to see your original post yet.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
An excellent translation of my translation!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Your post came across as a snide put down rather than a constructive comment.
|
|
|
|
|
Leif Simon Goodwin wrote: Your post came across as a snide put down rather than a constructive comment. Which tends to happen if you rub a volunteer the wrong way. You're not guaranteed a constructive comment on public forums.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I resent the use of the term spamming and the confrontational tone of your posting.
For your information I had an account with another name (company email, no longer accessible), posted in the WPF forum, got no answer after many days, posted a link in this forum, and got an answer almost immediately. Hence why I am/was not sure which was the best forum for the question.
|
|
|
|
|
|
Thank you for the constructive suggestion.
|
|
|
|
|
I have C# COM dll used in one of the module (lets call as A) and it already into the market.
For my other new module , i need same functionality as C# COM dll, So i used the same code and generated dll(the Common C# DLL is same for two modules and need to located in same place after installation)
Since C# COM dll name and location is same for both modules, i cant work on both the modules at a time
either i need to play with register /unregister and work with one module.
How can i make this C# COM dll with same name and same location to work for two projects/modules?
Help is greatly appreciated.
|
|
|
|
|
Member 11732139 wrote: i need same functionality as C# COM dll, So why are you creating a different dll?
|
|
|
|
|
the two modules are different and install packages of modules are different
when two modules insatlled in machine then common dll contradicts!!
|
|
|
|
|