This walkthrough should be particularly useful to you:
http://www.sqlteam.com/article/scripting-database-objects-using-smo-updated
And this is some related MSDN documentation:
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.aspx
And I'm not sure, but these classes may be of use to you, so you may want to look into them:
Microsoft.SqlServer.Management.Smo.Scripter
Microsoft.SqlServer.Management.Smo.StoredProcedure
And before you start anything, make sure to add a reference to this assembly:
Microsoft.SqlServer.Smo
The basic idea is that you'll script it out from one database then apply the script to another database. This is, of course, assuming that you want to do all this programmatically.