|
Hi Sir
Sir how can write code to change w[0] to Boolean
w[0]=0xAA;
mean w[0]=10101010;
i need change w[0] to Boolean value mean {true false true false true false true false}
also this
byte kk=0xAA;
mean kk=10101010;
i need change kk to Boolean value mean true false true false true false true false
Regards
modified 29-May-15 1:53am.
|
|
|
|
|
The below statement if (bool.TryParse(var[i], out v))---> says you whether it's really converting/not.if it returns true,then converting else returns false.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] var = {"abc","bcd","cde"};
public bool call(string[] var)
{
int i;
bool v;
for (i=0;i<var.Length;i++)
{
if (bool.TryParse(var[i], out v))
return v;
else
return v;
}
return true;
}
private void Form1_Load(object sender, EventArgs e)
{
bool b = call(var);
}
}
Remember it's not possible to convert string/string[] to bool.If tries it threw an exception of type 'System.FormatException',may not terminate the program but threw an exception.
|
|
|
|
|
Hello friends,
I am saving multiple Workitems of type Task but while saving it throws an exception "There is a problem on the server. Contact your Team Foundation Server administrator.
InnerException {"TF400732: The request has been canceled."} System.Exception {System.Web.Services.Protocols.SoapException}
why I am facing this issue? please help me to resolve this.
Thanks
Manoj Kumar
|
|
|
|
|
You given us nothing to work with except for the most generic error message TFS can throw.
Only you know the circumstances under which the problem occurs and there are a ton of possible causes, so start researching what everyone else has run into[^].
|
|
|
|
|
Thanks sir for your reply. Even I know its most generic error. my code is simple like
WorkItemType workItemType = teamProject.WorkItemTypes["Task"];
for(int i=0;i<100;i++)
{
WorkItem task = new WorkItem(workItemType);
task.Fields["somefield"].Value = "somevalue";
task.save();
}
exception comes at task.save. and value of I varies some times 2, some times 4 even some times it reaches 60.
|
|
|
|
|
I have no idea what's causing the problem as I've never done anything in code with TFS.
|
|
|
|
|
I want to calculate the size of the variable and not size of the data type. For example int anyValue=10;
what is the size of anyValue ?
(*Not calculate size of int)
NOTE:-->
So here anyValue size must be less from int datatype size.
|
|
|
|
|
You could do it by a loop that repeatedly right shifts the value until it reaches zero. The number of shifts gives the size.
|
|
|
|
|
Have a read of this Marshal.SizeOf[^]
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
The size of a variable is the size of the type it declared as: so for your example:
int anyValue = 10; the size of anyValue is always 32bits / 4 bytes because an int is a fixed size, regardless of what it contains.
This is even true for reference types: the variable which holds the reference will always be the same size:
Control c = button1; c is a reverence to a Control instance, so it will always be 32 bits or 64 bits depending on your your app is built and running.
The value it refers to can be different sizes in some cases: string, arrays, collections and so on can be variable sized1, but in general even a specific instance of a class will always be the same size. Value type instances are always the same size, they can't vary.
1: Even then, the collection instance is not a variable size, but the data it collects may be - the actual collection of objects is stored as an array of objects which is itself a reference.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi OriginalGriff,
int sizeOfVariable = Marshal.SizeOf('A');
int size = sizeof(Char);
Console.WriteLine("The size using marshal is {0} and SizeOf is {1} ",sizeOfVariable,size);
Console.Read();
Why the two result is different ??? :P
|
|
|
|
|
sizeof vs Marshal.SizeOf[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is where is starts to get complicated...
Because a Char is not the same everywhere!
'A' is a char - so it will normally return 2 because a Unicode character takes two bytes (an ASCII character takes one, but nearly all the time in .NET you are dealing with Unicode values)
So the sizeof(char) returns 2 because it needs two bytes of managed memory to store each char.
When you use Marshalling however, it isn't dealing with Managed memory, so it doesn't use Unicode - it uses ASCII instead. Because Marshalling is all about getting ready to talk to external non-NET applications, it can't just pass managed memory directly - because it might have to move it while the other application is using it - so it will effectively prepare a copy of the data in ASCII, because that is the older character standard that most apps used pre-NET.
So sizeof will give you the Managed size - 2
and Marshall.SizeOf gives you the unmanaged size - 1
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi OriginalGriff
Yess This is right Boss
|
|
|
|
|
What definition of "size" are you using here? Because normally it would be said that the size of anyValue is by definition the size of its type, it's a fixed-size type after all.
|
|
|
|
|
public interface IWTF
{
string SomeString { set; get; }
}
public static class WTF<T> where T : IWTF
{
public static string WTFMethod(IWTF i1, IWTF i2)
{
return i1.SomeString + i2.SomeString;
}
} Given the above: in some Method, in some instance-of-something-or-other, you call the 'WTFMethod in 'WTF:
WTF.WTFMethod(null, null); Of course, an error would be thrown as the 'WTFMethod was executed.
Which means (?): if I really want to make sure that I'm getting valid parameter inputs to 'WTFMethod:
public static string WTFMethod(IWTF i1, IWTF i2)
{
if (!(i1 is IWTF) || !(i2 is IWTF)) throw new ArgumentException("You Suck !");
return i1.SomeString + i2.SomeString;
} This lack-of-strong-typing (I don't know what else to call it) became apparent to me today while testing an Interface and its implementations.
Why ?
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
I assume in your second code block the generic type got lost while pasting it?
I can't see anything abnormal here - the compiler allows you to provide null for any reference type argument. The argument being an interface type doesn't matter.
But null is the only other possibility aside from a valid IWTF-reference, so you can replace the (i1 is IWTF) -checks with checking for null/non-null.
cheers, Sascha
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Hi, I'm new in C#, first of all sorry for my bad english.
I have a form, there is a login and a password input in my form.
I want to make a update query in a virtual machine, just a sample (I know the code isnt right):
UPDATE 'launcher' = 0 WHERE 'account' = textbox.Text and 'login' = textbox2.Text
--
So, whow can I make this? I know that to have privilegies I have to execute this from a php inside the machine where is the sql table.
Like my title says, I want to send the values account and password to a PHP in online machine, and that executa the query.
|
|
|
|
|
You have to send a HTTP Request to the machine where the web application is running. Construct the URL correctly, then send it, and collect the response. E.g.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
|
|
|
|
|
Thanks, if your type I found the solution in Internet!
|
|
|
|
|
Initially , I did row grouping in excel document using c#. Again I perform row grouping in between the (already grouped rows). same excel document the outline level will be increased.
I use below code
Excel.Range rng2 = sheet.get_Range((rg_row1 + 1) + ":" + (rg_row2 - 1), Missing.Value) as Excel.Range;
rng2.EntireRow.Group();
Please tell me why that outline level is increased?
How to maintain 2 levels?
|
|
|
|
|
I want clear understanding.
|
|
|
|
|
|
Just to add, the second example there is rather ambiguous.
Rather than having object , if you modify the code slightly to use string (string is still a reference type) as:
string name = "sandeep";
char[] values = {'s','a','n','d','e','e','p'};
string myName = new string(values);
Console.WriteLine("== operator result is {0}", name == myName);
Console.WriteLine("Equals method result is {0}", myName.Equals(name));
Console.ReadLine();
This is due to the CLR String pool -> the strings with same content reference to the same memory.
Just saying, if that interests the OP.
You have just been Sharapova'd.
|
|
|
|
|
It might be wise to call ReferenceEquals on your two strings to prove the point, or not, as the case may be.
Alan.
|
|
|
|