I'm not sure if there is a sample specific for changing a DID, but take a look at the CHM help file included, which has all the information you need. Look for the PhoneSystem class, which is the root entry point, and from there you can access all the information you need.
For example, invoking "PhoneSystem.Root.GetVoipProviders()" you will get an array of all the SIP trunks in your 3CX server. Then you can get the ExternalLine objects associated to that SIP trunk, and finally the DIDNumbers property will give you the DIDs for the lines. You can also get the inbound rules using the API. Please take a look at the docs for more details.
Kind regards.