|
hi,
i'm a new user and want to develop a mobile software in C#...
any can help me?
i'll be thankfull
|
|
|
|
|
Read the bit at the top of the page - "HOW TO GET AN ANSWER TO YOUR QUESTION".
Then try again. But this time, try following some of the instructions.
For example:
"hi" is a useless title. Try describing your problem.
ishaq shinwari wrote: i'm a new user and want to develop a mobile software in C#...
Is a useless description of your problem. Where are you stuck? What have you tried?
And so forth.
Go on, think about what you are trying to achieve. Or you will get no help at all - and likely, some abuse.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
How about using a search engine or checking on msdn.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi,
I've built a brand new application written in C# with VS2010 and I'm getting an error with my .rdlc file that states:
The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' which cannot be upgraded. e:\test\test1\test1\Report1.rdlc test1
This is a local report, not a server based report. I can create different reports against the data base using Report Builder with no issues. Note, I'm NOT trying to transport the files between Report Builder and VS2010. Am I forced into using Report Builder Server reports once I install SQL Server 2008 R2?
I would like to get this work as a local report and I'm not sure what is wrong. Any help is greatly appreciated.
Thank you,
Glenn
|
|
|
|
|
I writing Generic class and i need to restrict the type that that class can get.
I try to write it like this :
public class MyGeneric<t> where T : struct, IComparable, IFormattable, IConvertible, IComparable<t>, IEquatable<t>
{
T total;
public void foo(T val)
{
total +=val;
}
}
But in the foo(...) method - i get an error about the operator '+' can't applied to T.
|
|
|
|
|
int and double are not the only ValueType's, any struct is. They don't have to overload operator + .
Basically, you can't do this in C#
It's a shame really, I often wanted to do something like this and ended up writing huge workarounds.
Maybe in C# 4? I don't know.
|
|
|
|
|
Thanks,
I know about the 'valueType' and the 'struct'.
I'm using .net 4.0 - and i still did not found how to do it here.
I try to define in the 'where' an operator - but it not working.
|
|
|
|
|
How about dynamic , would that work? I haven't done much C# 4 programming so I'm not sure..
|
|
|
|
|
I dont see how 'dynamic' can help me here ( maybe i'm wrong )
|
|
|
|
|
dynamic supports operators and the like, right? So at least you'd be able to do that. What are your exact requirements?
|
|
|
|
|
Yes,
I try the dynamic already as the first solution - its not working as we expected in this case
|
|
|
|
|
Then I'm afraid what you want is impossible..
|
|
|
|
|
public class Foo<T> : IConvertible {
public void bar() {
T t = default(T);
((IConvertible)t) //Check out the intellisense
}
}
|
|
|
|
|
Sorry - this is not working.
|
|
|
|
|
This won't work, at least not in the way you want it... You are writing a numeric algorithm which should work upon different 'arithmetic' types and want to utilize arithmetic operators on T , right? This is not possible. There is no common base type for all 'numerics' which implements the appropriate operators (operators must be defined static on the type which implements them). Each CLR numeric type is implemented as a structure without common base (which is not supported for structures anyway), ergo you cannot restrict a type parameter in a generic to something which does not exists. The numeric types implement various interfaces, but these cannot implement operators since these must be static . So you are stuck, for the moment.
The only clean way (without CLR sourcery) is to define this non-existent common base:
public abstract class NumericBase<T> where T : struct {
public static NumericBase<T> operator + (NumericBase<T> pA, NumericBase<T> pB) {
return pA.Add(pB);
}
public static NumericBase<T> operator - (NumericBase<T> pA, NumericBase<T> pB) {
return pA.Sub(pB);
}
public abstract T Value { get; set; }
public abstract NumericBase<T> Add(NumericBase<T> pOther);
public abstract NumericBase<T> Sub(NumericBase<T> pOther);
}
Specialize for int :
public class NumericInt : NumericBase<int> {
public NumericInt() : this(0) {}
public NumericInt(int pValue) {
Value = pValue;
}
public override int Value { get; set; }
public override NumericBase<int> Add(NumericBase<int> pOther) {
return new NumericInt(Value + pOther.Value);
}
public override NumericBase<int> Sub(NumericBase<int> pOther) {
return new NumericInt(Value - pOther.Value);
}
}
And you can 'Foo ':
public class MySummator<T>
where T : struct {
public NumericBase<T> Result { get; set; }
public void Foo(NumericBase<T> pParameter) {
Result = Result + pParameter;
}
Clearly, you have a lot of overhead with virtual calls, so I would not use it that way in situations where performance is critical. On the other hand, you could use a bit of CLR sourcery here:
1. Write your algorithms using NumericBase<T> . You can run and test them and you are maintaing one generic common code base.
2. For real world usage System.Emit code, which is structurally identical to the generic NumericBase implementation, but uses concrete numeric types i.e. you replace NumericBase<int> with int and so on.
|
|
|
|
|
hi all,
normally in win app. or web app. I can take windows log on username with this code
"System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();"
but with windows service I can't do this, it takes like this:
"NT AUTHORITY\SYSTEM"
Howcan I do this with windows service??
thanks..
|
|
|
|
|
What account have you defined it to run under? Seems like Local System..
|
|
|
|
|
Go to your control panel-Admin Tools-Services and right click on the service, select properties -Log On tab ... have fun.
BTW,
System.Security.Principal.WindowsIdentity.GetCurrent().Name
is a string. If you call ToString on a string you look foolish. It is my personal crusade to get .NET developers to understand the concept of type.
|
|
|
|
|
Dumb answer of the day.
The service is running on a SERVER, the user name is what you started the service with. You nee dto get the username from the CLIENT and pass it to the service to record with the data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi.
I now know how to ask my question I have been trying to find out, without confusing people.
All I would like to do is take a string of digits
"123456789"
and get its byte representation (hex) value.
The above, 123456789 entered into the calculator gives :
75BCD15
How would I do that in c#
There, finaly I think I have put what I am trying (desperatly) to do. sorry for all the posts and proberbly need to say sorry for being so confusing.
Thank you in advance
Steve
|
|
|
|
|
Parse it as an int (or long if you expect it to be that big)
Then do something like string.Format("{0:X}", value) or value.ToString("X")
|
|
|
|
|
Thank you.
Yes, that works, but the string will be 41 digits long and I do not what to use bignum or anything.
I am trying to get this function to work, it did in c++, I have modified it but it produces the wrong hex value and I do not know why.
static int decodeSerial(String serial, byte[] result, int ResLen)
{
int m;
int digit;
Array.Clear(result, 0, ResLen);
for (int i = 0; i < serial.Length; i++)
{
digit = serial[i] - '0';
m = 0;
do
{
digit += result[m] * 10;
result[m++] = (byte)(digit % 255);
digit >>= 8;
}
while (m < ResLen);
}
return 0;
}
Thank you
Steve
|
|
|
|
|
Here is an implementation, together with a series of tests.
I'm not claiming it is anywhere near the optimum, I mimicked your code for as much as I liked it.
Given full freedom I would return a byte array of variable length and never have to signal an overflow.
private static void runAllTests() {
test("1");
test("1000");
test("1000000");
test("1000000000");
long j=1;
for(long i=0; i<63; i++) {
test(j.ToString());
j+=j;
}
test("-1");
test("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
}
private static void test(string decimalDigits) {
try {
byte[] bytes=decodeSerial(decimalDigits, 10);
string s=decimalDigits+" = ";
foreach (byte b in bytes) s+=" "+((int)b).ToString("X2");
log(s);
} catch (Exception exc) {
log(exc.ToString());
}
}
private static byte[] decodeSerial(string decimalDigits, int numberOfBytes) {
byte[] bytes=new byte[numberOfBytes];
foreach (char c in decimalDigits) {
int digit="0123456789".IndexOf(c);
if (digit<0) throw new ArgumentException("bad char in decodeSerial("+decimalDigits+")");
for (int m=0; m< numberOfBytes; m++) {
digit+=bytes[m]*10;
bytes[m]=(byte)(digit&0xFF);
digit>>=8;
}
if (digit!=0) throw new OverflowException("decodeSerial("+decimalDigits+","+numberOfBytes+")");
}
return bytes;
}
FYI: log(string s) is any method that somehow outputs a string, could be as simple as Console.WriteLine(s);
|
|
|
|
|
Thank you very much.
Obviosly I take it you now understand what I meant originaly?
It was hard to explain lol.
thank you again,
Steve
|
|
|
|
|
stephen.darling wrote: It was hard to explain
Not really, however you made it rather hard to understand. I summarized it in a three-line comment (I just added an example).
|
|
|
|