Shhow me a very simple one line example in C# to check if a given bit is set in given byte
function signature should be like
bool IsBitSet(Byte b,byte nPos)
{
return .....;
}
The Speed vs
This:
Console c = System.console();
String readline;
String u = c.readLine("%s", "args");
Throws a NullPointerException. Yet the signature of the method is:
public String readLine(String fmt, Object... args)
Why's this exception being thrown?
The signature of the hashCode() method is
public int hashCode(){
return x;
}
in this case x must be an int(primitive) but plz can anyone explain it to me that the number
which the hashCode() returns must be a prime number, even number...etc or there is no specification ? the reason behind i am asking this question is i have seen it in different ids the auto generated code always returns a prime number, so i need to know why?
thanks in advance
Given a ParameterInfo p from this:
void foo(int modopt(IsLong) n);
p.GetOptionalCustomModifiers() returns a System.Runtime.CompilerServices.IsLong; however, if the method signature happens to be:
void foo(out int modopt(IsLong) n);
It does not. Is there a work around for this?
Hi (it is propably stupid question)
how can acquire Domain class from database in test?
class PollServiceTests extends GrailsUnitTestCase {
Integer id = 1
void testSomething() {
Teacher teacher1 = Teacher.get(id)
assert teacher1 != null
}
}
I always get null or
No signature of method:
cz.jak.Teacher.get() is applicable for
argument types: (java.lang.Integer)
values: [1]
thanks a lot
Tom
Hey,
I'm trying to get the GUID of a given sharepoint URL. I don't mind using the API or the webservices or Sharepoint's database.
if i were to write a function, it's signature would be:
//get a GUID from path.
string GetGuidFromPath(string path){}
I had a lead: SPContentMapProvider but it doesn't seem to get the right info.
Thank you!
Very quick question for freshbooks oauth. When requesting a Request Token you need to provide (amoung others) the oauth_signature method.
Is the signature the consumer key and the consumer secret seperated by an ampersand? e.g.
_consumer_key_%26_consumer_secret_
where _consumer_key_ is the consumer key. _consumer_secret_ is the consumer secret and %26 is a urlencode ampersand.
I am binding a ListView a property that essentially wraps the Values collection (ICollection) on a generic dictionary.
When the values in the dictionary change, I call OnNotifyPropertyChanged(property). I don't see the updates on the screen, with no binding errors.
When I change the property getter to return the Linq extension dictionary.Values.ToList(), without changing the signature of the property (ICollection) it works with no problem.
Any reason why the Values collection bind and notify properly without projecting to an IList<?
I have a controller method with the following signature:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateValues(int id, MyViewModel[] array)
{
}
The id is normally picked up as part of the Url on other GET controller methods (I have a working route that does this)
I am successfully passing the array1 from the form in my view to the controller method, but how do I also put the id onto my Url so that when the user clicks the Submit button, the controller method will pick up the ID?
I've something like this
Object[] myObjects = ...(initialized in some way)...
int[] elemToRemove = new int[]{3,4,6,8,...}
What's the most efficient way of removing the elements of index position 3,4,6,8... from myObjects ?
I'd like to implement an efficient Utility method with a signature like
public Object[] removeElements(Object[] object, int[] elementsToRemove) {...}
The Object[] that is returned should be a new Object of size myObjects.length - elemToRemove.length
Are they same ?
Came across this line when reading about Java's main method's signature
"String args[ ] declares a parameter named args, which is an array of instances of the class String. Objects of type String store character strings."
As far as I know, the copy constructor must be of the Form T(const T&) or T(T&). What if I wanted to add default arguments to the signature?
T(const T&, double f = 1.0);
Would that be standards compliant?
Hi all,
i'd like to call a function using an array as a parameters:
var x = [ 'p0', 'p1', 'p2' ];
call_me ( x[0], x[1], x[2] ); // i don't like it
function call_me (param0, param1, param2 ) {
// ...
}
Is there a better way of passing the contents of x into call_me()?
Ps. I can't change the signature of call_me(), nor the way x is defined.
Thanks in advance
println args
println args.size()
println args.each{arg-> println arg}
println args.class
if (args.contains("Hello"))
println "Found Hello"
when ran give following error:
[hello, somethingelse]
2
hello
somethingelse
[hello, somethingelse]
class [Ljava.lang.String;
Caught: groovy.lang.MissingMethodException: No signature of method: [Ljava.lang.
String;.contains() is applicable for argument types: (java.lang.String) values:
[Hello]
why can I not do contains?
Hi,
both abstract and virtual are going to be override in child class than whats a difference.
is it Virtual method have body and abstract is just a signature ????
The .NET framework provides a few handy general-use delegates for common tasks, such as Predicate<T> and EventHandler<T>.
Is there a built-in delegate for the equivalent of CompareTo()?
The signature might be something like this:
delegate int Comparison<T>(T x, T y);
This is to implement sorting in such a way that I can provide a lambda expression for the actual sort routine (ListView.ListViewItemSorter, specifically), so any other approaches welcome.
During a make, I'm seeing an error along the lines of:
cc1: warnings being treated as errors
somefile.c:200: error: the frame size of 1032 bytes is larger than 1024 bytes
The line number points to the closing brace of a c function that has a signature like this:
void trace(SomeEnum1 p1, SomeEnum2 p2, char* format, ...) {
Anyone know what this type of error means in general?
I need something like this:
class Node (left : Node*, right : Node*)
I understand the ambiguity of this signature.
Is there a way around it better than the following?
class Node (left : Array[Node, right : Array[Node])
val n = new Node (Array(n1, n2), Array(n3))
Maybe some kind of separator like this?
val n = new Node (n1, n2, Sep, n3)
My question is not easy to explain using words, fortunately it's not too difficult to demonstrate. So, bear with me:
public interface Command<R>
{
public R execute();//parameter R is the type of object that will be returned as the result of the execution of this command
}
public abstract class BasicCommand<R>
{
}
public interface CommandProcessor<C extends Command<?>>
{
public <R> R process(C<R> command);//this is my question... it's illegal to do, but you understand the idea behind it, right?
}
//constrain BasicCommandProcessor to commands that subclass BasicCommand
public class BasicCommandProcessor implements CommandProcessor<C extends BasicCommand<?>>
{
//here, only subclasses of BasicCommand should be allowed as arguments but these
//BasicCommand object should be parameterized by R, like so: BasicCommand<R>
//so the method signature should really be
// public <R> R process(BasicCommand<R> command)
//which would break the inheritance if the interface's method signature was instead:
// public <R> R process(Command<R> command);
//I really hope this fully illustrates my conundrum
public <R> R process(C<R> command)
{
return command.execute();
}
}
public class CommandContext
{
public static void main(String... args)
{
BasicCommandProcessor bcp = new BasicCommandProcessor();
String textResult = bcp.execute(new BasicCommand<String>()
{
public String execute()
{
return "result";
}
});
Long numericResult = bcp.execute(new BasicCommand<Long>()
{
public Long execute()
{
return 123L;
}
});
}
}
Basically, I want the generic "process" method to dictate the type of generic parameter of the Command object. The goal is to be able to restrict different implementations of CommandProcessor to certain classes that implement Command interface and at the same time to able to call the process method of any class that implements the CommandProcessor interface and have it return the object of type specified by the parametarized Command object. I'm not sure if my explanation is clear enough, so please let me know if further explanation is needed. I guess, the question is "Would this be possible to do, at all?" If the answer is "No" what would be the best work-around (I thought of a couple on my own, but I'd like some fresh ideas)
I need to calculate permutations iteratively. The method signature looks like:
int[][] permute(int n)
For n = 3 for example, the return value would be:
[[0,1,2],
[0,2,1],
[1,0,2],
[1,2,0],
[2,0,1],
[2,1,0]]
How would you go about doing this iteratively in the most efficient way possible? I can do this recursively, but I'm interested in seeing lots of alternate ways to doing it iteratively.
Say I have a struct:
struct MyStruct
{
public int X
public int Y
}
And a method in some class that is iterated over many times elsewhere:
public bool MyMethod( MyStruct myStruct )
{
return ...
}
Is changing the MyMethod signature to the following an acceptable optimization?
public bool MyMethod( ref MyStruct myStruct )
If so, how much of an advantage would it really be? If not, about how many fields would a struct need for a big enough advantage using ref this way?
Hello.
I have the function with following signature:
void box_sort(int**, int, int)
and variable of following type:
int boxes[MAX_BOXES][MAX_DIMENSIONALITY+1]
When I am calling the function
box_sort(boxes, a, b)
GCC gives me two warnings:
103.c:79: warning: passing argument 1 of ‘box_sort’ from incompatible pointer type (string where i am calling the function)
103.c:42: note: expected ‘int **’ but argument is of type ‘int (*)[11] (string where the function is defined)
The question is why? Whether int x[][] and int** x (and actually int* x[]) are not the same types in C?
If I have a method signature like
public string myMethod<T>( ... )
How can I, inside the method, get the name of the type that was given as type argument? I'd like to do something similar to typeof(T).FullName, but that actually works...
Say you had a timestamp function and then wanted to create a new function to combine your timestamp and Console.WriteLine(), e.g.
public static void Write(string msg)
{
WriteTimeStamp();
Console.WriteLine( msg );
}
But the WriteLine() method has 18 or so overloads, which will not be reflected in the signature of the wrapper function. How would you have the wrapper take non-strings and pass them on to WriteLine()?
I need write a live messenger plugin which periodically read messages from a remote http server, and then change my signature(the short message after my name) accordingly.
Can anyone point me to any open source project or materials where I can get started?
Thanks.