I have 1 NSMutableArray and I want to convert whatever data in array will be in NSString.
tell me code for that. Array is nothing but object of NSMutableArray class.
I am coding in Visual Basic. I am using a checkbox control. Now depending on its checked property I need to set/unset a bit column in a SQL Server database. Here's the code:
Try
conSQL.Open()
Dim cmd As New SqlCommand("update Student set send_mail = " + _
sendemailCheckBox.Checked.ToString + " where student_id = '" _
+ sidnolabel.Text + "'", conSQL)
cmd.ExecuteNonQuery()
Finally
conSQL.Close()
End Try
The send_mail attribute is of bit datatype. This code is not working.
How do I go about it?
how do i do enumeration in sqlachemy? im using pylons if it matters. i also want to have in code to create different object depends on the enumeration, with the same parameters, but different object class.
Title probably doesn't make a lot of sense, so I'll start with some code:
class Foo : public std::vector<Foo>
{
};
...
Foo f;
f.push_back( Foo() );
Why is this allowed by the compiler? My brain is melting at this stage, so can anyone explain whether there are any reasons you would want to do this? Unfortunately I've just seen a similar pattern in some production C# code and wondered why anyone would use this pattern.
Hello, I've got some problem with my function and don't know how to solve this problem, This is my code:
ListResult result=listFind(currentLines, compareBasicLines, &linePrototype); <-here problem
compareBasicLines pointer to function
int compareBasicLines(ptrLine line1, ptrLine line2){
COMPARE_NUMBER_STRINGS(line1, line2);
}
COMPARE_NUMBER_STRINGS(line1, line2); defined in another file
#define COMPARE_NUMBER_STRINGS(var1, var2) \
if(var1 == NULL || var2 == NULL){ \
return 0; \
} \
return strcmp(var1->strNumber, var2->strNumber);
thanks in advance for everyone
I have the following function (which worked in Visual Studio):
bool Plane::contains(Vector& point){
return normalVector.dotProduct(point - position) < -doubleResolution;
}
When I compile it using g++ version 4.1.2 , I get the following error:
Plane.cpp: In member function âvirtual bool Plane::contains(Vector&)â:
Plane.cpp:36: error: no matching function for call to âVector::dotProduct(Vector)â
Vector.h:19: note: candidates are: double Vector::dotProduct(Vector&)
So as you can see, the compiler thinks (point-position) is a Vector but it's expecting Vector&.
What's the best way to fix this?
I verified that this works:
Vector temp = point-position;
return normalVector.dotProduct(temp) < -doubleResolution;
But I was hoping for something a little bit cleaner.
I heard a suggestion that adding a copy constructor might help. So I added a copy constructor to Vector (see below), but it didn't help.
Vector.h:
Vector(const Vector& other);
Vector.cpp:
Vector::Vector(const Vector& other)
:x(other.x), y(other.y), z(other.z), homogenous(other.homogenous) {
}
I made this. Is this the fastest way to find lastest DateTime of my collection of DateTimes?
I'm wondering if there is a method for what i'm doing inside the foreach, but even if there is, I can't see how it can be faster than what i all ready got.
List<StateLog> stateLogs = db.StateLog.Where(p => p.ProductID == product.ProductID).ToList();
DateTime lastTimeStamp = DateTime.MinValue;
foreach (var stateLog in stateLogs)
{
int result = DateTime.Compare(lastTimeStamp, stateLog.TimeStamp);
if (result < 0)
lastTimeStamp = stateLog.TimeStamp; // sæt fordi timestamp er senere
}
Hi!
I'm a c# guy giving Java a try .. so how would I do the following in java.
in C#
public T create_an_instance_of<T>(){
T instance = default (T);
// here's usually some factory to create the implementation
instance = some_factory.build<T>();
// or even..
instance = some_factory.build(typeOf(T) );
return instance;
}
for something like www.9gag.com , which open source mvc framework can be used? in particular the main page, with highly rated content is what i am looking for.. along with an option for users to thumbs up/heart every article/post/blog/vlog/podcast/link.
i have passportno(varchar) in database.
i am entering values like this 001,002,003. and i want to display like sorting order.
now i wrote query like this "select * from passport_registration where status=1 ORDER BY passportno" then displaying output like this......077,088,099,100,1000,1001,1009,101,1010
i want to diplay sort order. how to do?
int newWidth = 100;
int newHeight = 100;
double ratio = 0;
if (img1.Width > img1.Height)
{
ratio = img1.Width / img1.Height;
newHeight = (int)(newHeight / ratio);
}
else
{
ratio = img1.Height / img1.Width;
newWidth = (int)(newWidth / ratio);
}
Image bmp1 = img1.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);
bmp1.Save(Server.MapPath("~/Uploads/Photos/Thumbnails/") + photo.PhotoID + ".jpg");
I always get Image with both height and width having same values (100)
I am obiously doing something wrong with type conversion?
Hi
I have the following code sample, where the only difference between the 2 parts of the If statement is the less than/greater than operators.
Is there a better way to write this? Could almost do with being able to define an Operator variable.
If myVar = true Then
Do While (X < Y)
'call Method A
Loop
Else
Do While (X > Y)
'call Method A
Loop
End If
thanks
Hi
asp.net mvc 2
I have this action in Identity controller
public ActionResult Details(string id, MessageUi message)
{
And I'm trying to redirect to this action from another controller, but I don't know how should I pass the message parameter
I was trying with
var id = "someidvalue"
var message = new MessageUi("somevalue");
return RedirectToAction("Details", "Identity", new { id, message});
}
but message parameter is null
I am trying to use the model ListModel as a generic list model. I would like to enter on the page
@Html.DisplayForModel()
However the MVC is not correctly finding the templated file "ListModel.cshtml". It must work differently for generic models. What should I name the templated file in order for it to correctly be located?
public class ListModel<T>
{
public IEnumerable<T> Models {get;set;}
public string NextPage {get;set;}
}
I would expect it to look for "Shared/DisplayTemplates/ListModel.ascx" but it doesn't. Does anyone know?
I wonder if syntax as follows would be helpful in your opinion as a code readability improvent and self-commenting of code:
std::map<std::string name, std::vector<int> scores> myMap;
In this example it clearly says and no other comment is needed, what for we are using myMap variable.
Looking forward to your opinions.
I have no experience with windows application hooking, DLL injection etc. What is the simplest way to achieve that described in the title and nothing else?
I use opencsv to parse csv files, and my code is
while( (line = reader.readNext()) != null ) { .... }
I got a compiler warning saying:
comparing values of types Unit and Null using `!=' will always yield true
[warn] while( (aLine = reader.readNext()) != null ) {
How should I do the while loop?
I have (for example) Dictionary of different generic types (d1, d2, d3, d4) and I want to store them in something
var d1 = new Dictionary<int, string>();
var d2 = new Dictionary<int, long>();
var d3 = new Dictionary<DateTime, bool>();
var d4 = new Dictionary<string, object>();
var something = ??? //new List<object> {d1, d2, d3, d4};
Is there any other way how to store that in something with common denominator different than object?
Thanks :-)
I have some doubt as follows
We are UPDATING a field in SQL and ALTER the row also.After giving the COMMIT command the system is crashed.Wat will happen to the commands given,whether it will UPDATE and ALTER the table r not?
I have the following model associations:
Response->Survey
Response->Question
Response->Choice
Survey->Question
Question->Choice
I want to create a form where I could answer all the questions for one survey. So I used the following to return the needed data:
$questions = $this->Response->Question->find('all', array(
'conditions' => array('survey_id' => $id),
'contain' => array('Choice')
)
);
Sample output for debug($questions).
Questions
Is there a contain() option so that an associated model returns in the find('list') format so that I could use:
foreach($question as $questions) {
$this-Form-select('field_name', $question['Choice']);
}
If no option is available, how could I do this using PHP's builting array methods?
PS: The foreach block won't turn into a code block. If someone could edit and fix it, please do so and delete this line. Thank you.
Imagine I have a Map[String, String] in Scala.
I want to match against the full set of key–value pairings in the map.
Something like this ought to be possible
val record = Map("amenity" -> "restaurant", "cuisine" -> "chinese", "name" -> "Golden Palace")
record match {
case Map("amenity" -> "restaurant", "cuisine" -> "chinese") => "a Chinese restaurant"
case Map("amenity" -> "restaurant", "cuisine" -> "italian") => "an Italian restaurant"
case Map("amenity" -> "restaurant") => "some other restaurant"
case _ => "something else entirely"
}
The compiler complains thulsy:
error: value Map is not a case class constructor, nor does it have an unapply/unapplySeq method
What currently is the best way to pattern match for key–value combinations in a Map?
I want to create tables that contain geometry data types (Mysql spatial extension). which steps are needed to map these with Doctrine 1.2?
Any idea how is the codes of yaml mapping and corresponding modal class for custom data mapping with Doctrine 1.2?
Thanks.