|
Why understanding pass by value and past by reference are important in order to learn a programming language?
|
|
|
|
|
When you are passing something to another function, it can get modified within that.
The importance comes into picture if you want to know what happens after the function returns. If you do not care about the post-return stage, then you can pass by value/reference, it doesn't affects your application logic in anyway. However, if you are concerned with the after value, you need to pass by reference.
Apart, given the framework implementation, an object is a heavyweight construct. So if we keep on passing such a huge object by creating a copy, it will hog up memory causing hung application and GC trigger. Hence the framework will auto (most i believe) will pass an object by reference and cause any changes to that be available outside the function as well. You can also pass a value type (structure) as reference, in which case it will be boxed into a reference type and then passed.
C# allows you to explicitly specify "ref" and "out" decorators on parameters. If applied either, the changes are visible after the function return, else by default it gets passed as value.
|
|
|
|
|
Take a look at .NET Book Zero[^], where Charles Petzold expalins it in very good detail.
Veni, vidi, abiit domum
|
|
|
|
|
|
Well, it seems more clear by now, thank you 
|
|
|
|
|
Hello everyone,
I am new to these forums and pretty much new to programming. I am, though, very willing to learn.
So, I am working on a personal project which involves creating a website where users should be able to have their own profiles.
I found the following software which can help me do this: http://www.boonex.com/dolphin[]
I am unsure of if it is a good idea to use it? Should I try to program the website from scratch instead? Will this take forever, though? Do any of you have any suggestions on how I should move forward with this?
Thank you so much for taking the time to look at my post!
|
|
|
|
|
Welcome.
It's pretty much impossible to answer your questions. We know nothing about that library, what it does, what it takes to use it, if it will suit your requirements, ...
We also know absolutely nothing about you, what your skill set is, your experience with .NET, HTML, CSS, databases, previous apps you've written, ...
|
|
|
|
|
Hi,
It depends on a few things:
a)does it do what you what ?
b)is it open source or not ?
c)is the library maintained by the company that developed it ?
If not, you will find your self later in the situation to change the library.
Regards,
Paul Joseph.
|
|
|
|
|
Hi guys!..
This is my first post so i hope you can help me .
I have this WMI query that the idea is that will call the namespace MicrosoftBizTlakServer from 2 biztalk servers in order to see if they are running a Receive Location.
I've tried to fix this but i can't see the problem.
All i get is that the Class is not valid.
Any ideas of what i'm i doing wrong?.
Thanks so much!!
Regards.
Francisco.
Here is the query:
# Receive Location Test
use strict;
use Win32::OLE qw(in with);
use constant EOL => "\r\n";
use constant false => 0;
use constant true => 1;
use constant TEST_CODE =>0;
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
###############################################################################
# Collect all the system parameters
###############################################################################
# !*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
# Set / replace the following specfic variables for your specific WMI collection
my $root = "root\\MicrosoftBizTalkServer";
my @variables = ("Name", "ReceivePortName","IsDisabled");
my $sqlQuery = "select ".join(",",@variables)." from MSBTS_ReceiveLocation";
my ($strUser, $strPasswd, $strDomain);
my $res2Site;
my $device_ip = "127.0.0.1";
if (!TEST_CODE) {
my ($model_name,$version_name,$vendor_name,$pl_name,$device_sn,$device_name);
get_device_info($device_ip,$model_name,$version_name,$vendor_name,$pl_name,$device_sn,$device_name);
}
if (TEST_CODE) {
$strUser = "administrator";
$strPasswd = "painter";
$strDomain = "";
} else {
my %protocol_settings = get_protocol_settings('WMI');
$strUser = $protocol_settings{"Username"};
$strPasswd = $protocol_settings{"Password"};
$strDomain = $protocol_settings{"Domain"};
}
my $objWMILocator = Win32::OLE->CreateObject("WbemScripting.SWbemLocator");
my $objWMIService = "";
if ($device_ip eq "127.0.0.1") {
$objWMIService = Win32::OLE-> GetObject("winmgmts:\\\\$device_ip\\$root");
} else {
$objWMIService = $objWMILocator->ConnectServer($device_ip, $root, $strDomain."\\".$strUser, $strPasswd);
}
if (not $objWMIService) { # for the local machine you may use ($objWMIService = Win32::OLE-> GetObject("winmgmts:\\\\$device_ip\\root\\MicrosoftBizTalkServer"))
print "WMI Moniker ERROR:".Win32::OLE->LastError.EOL;
$res2Site .= "ERROR: Remote machine unreachable".EOL;
print "$res2Site" if TEST_CODE;
wmi_set_result($res2Site) unless TEST_CODE;
exit 0;
}
my $ret = exec_query($sqlQuery);
print $res2Site if TEST_CODE;
wmi_set_result($res2Site) unless TEST_CODE;
################################# SubRoutines ##################################
sub exec_query {
my $query = $_[0];
my $colItems;
$res2Site = "";
if (not ($colItems = $objWMIService-> ExecQuery($query,"WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly)) )
{
print "WMI ExecQuery ERROR:", Win32::OLE->LastError;
}
$res2Site .= "WMI query result:\n";
$res2Site .= "==================================================\n";
my $entryCounter = 0;
foreach my $key (in $colItems)
{
$entryCounter++;
$res2Site .= "\[WMIClassInstance_$entryCounter\]\n";
foreach (@variables)
{
my $val = ($key->{$_})/10;
$res2Site .= "$_=$val\n";
}
}
$res2Site .= "==================================================\n";
$res2Site .= "Number of Instances: $entryCounter";
}
|
|
|
|
|
Currently i am using Netscaler VPX that does content switching, load balancing . request url re-direct all by itself but it is too costly like 60$/day.
All i am looking for an alternative for that, please do comment
every suggestion is welcome
|
|
|
|
|
What is a good programming language to learn to make apps that will work on all platforms even ipad, etc etc...
I think there is
java, html 5, javascript
and thats all i can think of, but not sure about java though, dose anyone know any?
|
|
|
|
|
You can use Xamarin to write apps in C# which will run on Windows, Mac, iOS and Android. Unfortunately, the free version is quite limited, and the paid-for versions are quite expensive.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I would recommend Java with all it's parts: J2SE, J2EE(for web) J2ME(for mobiles).
AT this moment it is supported on all platforms.
Regards,
Paul.
|
|
|
|
|
Currently it would be the combination of Javascript with HTML5 and CSS3. Only one is a programming language but the group is what makes is great.
You could focus on Java, but I am not sure it would be supported in as many situations.
Regards
|
|
|
|
|
I'm starting to learn Clojure using using Lein, however I can't see to get lein to work properly. I used the Windows installer and everything seemed to work fine; no error message and all code I enter in REPL works fine. However when I try to run an example from the book I reading ("Programming Clojure" by Stuart Halloway) I get an error message.
Specifically the book has a section on using libraries where it shows how to use an example from the source code provided. It shows to enter (require 'examples.introduction) . The error message I get is:
FileNotFoundException Could not locate examples/introduction__init.class or examples/introduction.clj on classpath: clojure.lang.RT.load (RT.java:443)
I know that the introduction.clj file exist at ../Desktop/Programming/code/src/examples/introduction.clj and there is also a project.clj file that exist at ../Desktop/Programming/code/project.clj
From trying to provide the path in different formats, and what I've read online, it seems like I need to set the directory of my project for lein to find the ../examples/introduction.clj , but I haven't found how to do this. I've read the tutorial on lein website and have tried going through it step by step but still nothing.
Can anyone provide guidance on how I can get lein to find the file that I specify using the (require) ? This is the first day I'm using Clojure. Thanks in advance.
|
|
|
|
|
Set your classpath variable to include the full path of the directory, e.g. C:/Desktop/Programming/code/src .
Use the best guess
|
|
|
|
|
Hello, not sure if I am in the right spot to post my question about PowerShell/PowerCLI
I have a script in powershell that will send an email to an outlook client. The msg body will have values regarding to two things: Active Snapshots in the virtual environment and CD ROMs attached to the VMs.
Let's talk when the email reports more that one CDRoms attached, how do I increase or decrease the msg body depending of the results gathered from the virtual environment ?
So, far I have this code:
if (($Snapshots -eq "yes") -or ($cdroms -eq "yes"))
{
$array0 = @()
$array1 = @()
$array2 = @()
$array3 = @()
start-sleep 1
connect-VIServer $vcserver
$array0 += Get-VM | get-snapshot | %{$_.VM.Name}
$array1 += Get-VM | get-snapshot | select-object -expandproperty Name
$array2 += Get-VM | get-snapshot | select-object -expandproperty Created
$array3 =@(Get-VM | where { $_ | Get-CDdrive | where { $_.ConnectionState.Connected -eq "true" } } | Select-object -ExpandProperty Name)
$i = 0
$j = 0
Do {
$msg.Body += "<FONT COLOR=black>VMware HealthCheck vCenter2</FONT><BR><BR>" + `
"<B><FONT COLOR=black>Snapshots Active</FONT></B><BR>" + `
"<B><FONT COLOR=black>VM Name</FONT></B>"+`
"<B><FONT COLOR=black> `
Name</FONT></B>"+`
"<B><FONT COLOR=black> `
Created</FONT></B><BR>"+`
"<FONT COLOR=Red>"+$array0+"</FONT>"+`
"<FONT COLOR=Red> "+$array1+"</FONT>"+`
"<FONT COLOR=Red> "+$array2+"</FONT><BR><BR>"+`
"<B><FONT COLOR=black>CDROMS Connected (Bad Habit)</FONT></B><BR>"+"<B><FONT COLOR=black>VM Name</FONT></B><BR>"+"<FONT COLOR=Red>"+$array3+"</FONT>"
$i++
$j++
The output i get is:
From: VMware Healtcheck
Sent: Thursday, June 20, 2013 1:26 PM
To: Me
Subject: VMware Health UPIvCenter2
VMware HealthCheck vCenter2
Snapshots Active
VM Name Name Created
VEEAM1 VEEAM1 Test1 Test2 06/20/2013 09:06:09 06/20/2013 09:31:15
CDROMS Connected (Bad Habit)
VM Name
MAILGATE
And would like to have is:
From: VMware Healtcheck
Sent: Thursday, June 20, 2013 1:26 PM
To: Me
Subject: VMware Health UPIvCenter2
VMware HealthCheck vCenter2
Snapshots Active
VM Name Name Created
VEEAM1 Test1 06/20/2013 09:06:09
VEEAM1 Test2 06/20/2013 09:31:15
CDROMS Connected (Bad Habit)
VM Name
MAILGATE
I can have multiple snapshots or multiple VMs with CD Roms connected. Thanks for your help.
|
|
|
|
|
I never thought that I would one day ask this question or anything like it. But here goes ...
I'm running Ubuntu 12.10. I want to run your "Desktop Display" program. The instructions tell me to run two lines of code:
ImageStreamingServer server = new ImageStreamingServer();
server.Start(8080);
Where and how????
I presume I have to create a java file, but how?
Thanks in advance.
|
|
|
|
|
Member 10115288 wrote: I want to run your "Desktop Display" program. Who is this message supposed to be aimed at?
Use the best guess
|
|
|
|
|
|
i have created a Wpf Database Application.
Now i want to make Setup for it to install on clients machine.
But it should be Activate for only 1 year without Internet connection.
How can i do this Activation.
Help me.
|
|
|
|
|
Hi, if you're reading this, thanks for taking the time to help me with this.
I have been given an assignment in which I need to remake the game Reversi/Othello in MatLAB using an 8x8 matrix where black is 1 and white is -1, and have a functional GUI.
I have been able to do the GUI etc, by myself, but when I reach the point where I need to allow for only valid moves, I become a little stuck.
I was curious if any of you would know of a way in which that could be done, because I've hit a road block. Essentially I need to scan all 8 directions of the matrix from the centre point, and find a valid combination of player_number*-1, in a row which end in a player_number (where player_number is the current players turn), but I am not sure how to accomplish this.
Again, thanks for your time.
|
|
|
|
|
|
|
Proxy can help you. try it!
/* LIFE RUNS ON CODE */
|
|
|
|
|